n8n-nodes-runrunit 0.2.14 → 0.2.16

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.
Files changed (32) hide show
  1. package/package.json +59 -59
  2. package/dist/credentials/RunrunitApi.credentials.d.ts +0 -9
  3. package/dist/credentials/RunrunitApi.credentials.js +0 -76
  4. package/dist/credentials/RunrunitApi.credentials.js.map +0 -1
  5. package/dist/icons/runrunit.dark.svg +0 -13
  6. package/dist/icons/runrunit.svg +0 -13
  7. package/dist/nodes/Runrunit/RunrunitApi.node.d.ts +0 -6
  8. package/dist/nodes/Runrunit/RunrunitApi.node.js +0 -402
  9. package/dist/nodes/Runrunit/RunrunitApi.node.js.map +0 -1
  10. package/dist/nodes/Runrunit/RunrunitApi.node.json +0 -18
  11. package/dist/nodes/Runrunit/resources/Tasks/create.d.ts +0 -2
  12. package/dist/nodes/Runrunit/resources/Tasks/create.js +0 -71
  13. package/dist/nodes/Runrunit/resources/Tasks/create.js.map +0 -1
  14. package/dist/nodes/Runrunit/resources/Tasks/delete.d.ts +0 -2
  15. package/dist/nodes/Runrunit/resources/Tasks/delete.js +0 -5
  16. package/dist/nodes/Runrunit/resources/Tasks/delete.js.map +0 -1
  17. package/dist/nodes/Runrunit/resources/Tasks/get.d.ts +0 -2
  18. package/dist/nodes/Runrunit/resources/Tasks/get.js +0 -23
  19. package/dist/nodes/Runrunit/resources/Tasks/get.js.map +0 -1
  20. package/dist/nodes/Runrunit/resources/Tasks/index.d.ts +0 -2
  21. package/dist/nodes/Runrunit/resources/Tasks/index.js +0 -111
  22. package/dist/nodes/Runrunit/resources/Tasks/index.js.map +0 -1
  23. package/dist/nodes/Runrunit/resources/Tasks/options.d.ts +0 -2
  24. package/dist/nodes/Runrunit/resources/Tasks/options.js +0 -5
  25. package/dist/nodes/Runrunit/resources/Tasks/options.js.map +0 -1
  26. package/dist/nodes/Runrunit/resources/Tasks/update.d.ts +0 -2
  27. package/dist/nodes/Runrunit/resources/Tasks/update.js +0 -71
  28. package/dist/nodes/Runrunit/resources/Tasks/update.js.map +0 -1
  29. package/dist/nodes/Runrunit/runrunit.dark.svg +0 -13
  30. package/dist/nodes/Runrunit/runrunit.svg +0 -13
  31. package/dist/package.json +0 -61
  32. package/dist/tsconfig.tsbuildinfo +0 -1
package/package.json CHANGED
@@ -1,61 +1,61 @@
1
1
  {
2
- "name": "n8n-nodes-runrunit",
3
- "version": "0.2.14",
4
- "description": "RunRun.it Rest API Node compatible with RunRun.it.",
5
- "license": "MIT",
6
- "homepage": "https://github.com/YeshShareDEV/n8n-nodes-runrun.it.git",
7
- "keywords": [
8
- "n8n-community-node-package",
9
- "n8n",
10
- "runrun.it",
11
- "it-management",
12
- "ticket-system"
13
- ],
14
- "author": {
15
- "name": "YeshShareDEV",
16
- "email": "contato@yeshshare.com.br"
17
- },
18
- "repository": {
19
- "type": "git",
20
- "url": "https://github.com/YeshShareDEV/n8n-nodes-runrun.it.git"
21
- },
22
- "scripts": {
23
- "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true});\" && n8n-node build",
24
- "build:watch": "tsc --watch",
25
- "dev": "n8n-node dev",
26
- "lint": "n8n-node lint",
27
- "lint:fix": "n8n-node lint --fix",
28
- "release": "n8n-node release",
29
- "ver:rc": "npm version prerelease --preid=rc -m \"chore(release): %s\" && git push --follow-tags",
30
- "ver:patch": "npm version patch -m \"chore(release): %s\" && git push --follow-tags",
31
- "ver:minor": "npm version minor -m \"chore(release): %s\" && git push --follow-tags",
32
- "ver:major": "npm version major -m \"chore(release): %s\" && git push --follow-tags"
33
- },
34
- "files": [
35
- "dist"
36
- ],
37
- "n8n": {
38
- "n8nNodesApiVersion": 1,
2
+ "name": "n8n-nodes-runrunit",
3
+ "version": "0.2.16",
4
+ "description": "RunRun.it Rest API Node compatible with RunRun.it.",
5
+ "license": "MIT",
6
+ "homepage": "https://github.com/YeshShareDEV/n8n-nodes-runrun.it.git",
7
+ "keywords": [
8
+ "n8n-community-node-package",
9
+ "n8n",
10
+ "runrun.it",
11
+ "it-management",
12
+ "ticket-system"
13
+ ],
14
+ "author": {
15
+ "name": "YeshShareDEV",
16
+ "email": "contato@yeshshare.com.br"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/YeshShareDEV/n8n-nodes-runrun.it.git"
21
+ },
22
+ "scripts": {
23
+ "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true});\" && n8n-node build",
24
+ "build:watch": "tsc --watch",
25
+ "dev": "n8n-node dev",
26
+ "lint": "n8n-node lint",
27
+ "lint:fix": "n8n-node lint --fix",
28
+ "release": "n8n-node release",
29
+ "ver:rc": "npm version prerelease --preid=rc -m \"chore(release): %s\" && git push --follow-tags",
30
+ "ver:patch": "npm version patch -m \"chore(release): %s\" && git push --follow-tags",
31
+ "ver:minor": "npm version minor -m \"chore(release): %s\" && git push --follow-tags",
32
+ "ver:major": "npm version major -m \"chore(release): %s\" && git push --follow-tags"
33
+ },
34
+ "files": [
35
+ "dist"
36
+ ],
37
+ "n8n": {
38
+ "n8nNodesApiVersion": 1,
39
39
  "strict": true,
40
- "credentials": [
41
- "dist/credentials/RunrunitApi.credentials.js"
42
- ],
43
- "nodes": [
44
- "dist/nodes/RunrunitApi.node.js"
45
- ]
46
- },
47
- "devDependencies": {
48
- "@n8n/node-cli": "*",
49
- "eslint": "9.32.0",
50
- "n8n-workflow": "^1.120.9",
51
- "prettier": "^3.6.2",
52
- "release-it": "^19.0.4",
53
- "typescript": "5.9.2"
54
- },
55
- "peerDependencies": {
56
- "n8n-workflow": "*"
57
- },
58
- "dependencies": {
59
- "change-case": "4.1.2"
60
- }
61
- }
40
+ "credentials": [
41
+ "dist/credentials/RunrunitApi.credentials.js"
42
+ ],
43
+ "nodes": [
44
+ "dist/nodes/Runrunit/RunrunitApi.node.js"
45
+ ]
46
+ },
47
+ "devDependencies": {
48
+ "@n8n/node-cli": "*",
49
+ "eslint": "9.32.0",
50
+ "n8n-workflow": "^1.120.9",
51
+ "prettier": "^3.6.2",
52
+ "release-it": "^19.0.4",
53
+ "typescript": "5.9.2"
54
+ },
55
+ "peerDependencies": {
56
+ "n8n-workflow": "*"
57
+ },
58
+ "dependencies": {
59
+ "change-case": "4.1.2"
60
+ }
61
+ }
@@ -1,9 +0,0 @@
1
- import type { ICredentialType, ICredentialTestRequest, INodeProperties, Icon } from 'n8n-workflow';
2
- export declare class RunrunitApi implements ICredentialType {
3
- name: string;
4
- displayName: string;
5
- icon: Icon;
6
- documentationUrl: string;
7
- test: ICredentialTestRequest;
8
- properties: INodeProperties[];
9
- }
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RunrunitApi = void 0;
4
- class RunrunitApi {
5
- constructor() {
6
- this.name = 'runrunitApi';
7
- this.displayName = 'Runrun.it API';
8
- this.icon = { light: 'file:../icons/runrunit.svg', dark: 'file:../icons/runrunit.dark.svg' };
9
- this.documentationUrl = 'https://atendimento.centrium.com.br/api.php/v2.1/doc.JSON';
10
- this.test = {
11
- request: {
12
- url: '={{$credentials.host.replace(/\\/+$/, "") + "/api.php"}}/token',
13
- method: 'POST',
14
- headers: {
15
- 'Content-Type': 'application/json',
16
- },
17
- body: '={"grant_type":"password","client_id":"' + "{{$credentials.clientId}}" + '","client_secret":"' + "{{$credentials.clientSecret}}" + '","username":"' + "{{$credentials.username}}" + '","password":"' + "{{$credentials.password}}" + '","scope":"' + "{{$credentials.scope}}" + '"}',
18
- },
19
- };
20
- this.properties = [
21
- {
22
- displayName: 'Runrun.it URL',
23
- name: 'host',
24
- type: 'string',
25
- default: '',
26
- placeholder: 'https://runrun.example.com',
27
- required: true,
28
- description: 'URL base do Runrun.it (sem /api.php - será adicionado automaticamente)',
29
- },
30
- {
31
- displayName: 'Scope',
32
- name: 'scope',
33
- type: 'string',
34
- default: 'api graphql',
35
- required: true,
36
- description: 'Escopos de acesso para o token OAuth2 (ex: api graphql)',
37
- },
38
- {
39
- displayName: 'Client ID',
40
- name: 'clientId',
41
- type: 'string',
42
- required: true,
43
- default: '',
44
- description: 'Client ID gerado no Runrun.it (Setup > OAuth Clients)',
45
- },
46
- {
47
- displayName: 'Client Secret',
48
- name: 'clientSecret',
49
- type: 'string',
50
- typeOptions: { password: true },
51
- required: true,
52
- default: '',
53
- description: 'Client Secret gerado no Runrun.it',
54
- },
55
- {
56
- displayName: 'Username',
57
- name: 'username',
58
- type: 'string',
59
- required: true,
60
- default: '',
61
- description: 'Usuário do Runrun.it a ser autenticado',
62
- },
63
- {
64
- displayName: 'Password',
65
- name: 'password',
66
- type: 'string',
67
- typeOptions: { password: true },
68
- required: true,
69
- default: '',
70
- description: 'Senha do usuário do Runrun.it',
71
- },
72
- ];
73
- }
74
- }
75
- exports.RunrunitApi = RunrunitApi;
76
- //# sourceMappingURL=RunrunitApi.credentials.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RunrunitApi.credentials.js","sourceRoot":"","sources":["../../credentials/RunrunitApi.credentials.ts"],"names":[],"mappings":";;;AAEA,MAAa,WAAW;IAAxB;QACC,SAAI,GAAG,aAAa,CAAC;QAErB,gBAAW,GAAG,eAAe,CAAC;QAE9B,SAAI,GAAS,EAAE,KAAK,EAAE,4BAA4B,EAAE,IAAI,EAAE,iCAAiC,EAAE,CAAC;QAE9F,qBAAgB,GAAG,2DAA2D,CAAC;QAE/E,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,GAAG,EAAE,gEAAgE;gBACrE,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACR,cAAc,EAAE,kBAAkB;iBAClC;gBACD,IAAI,EACH,yCAAyC,GAAG,2BAA2B,GAAG,qBAAqB,GAAG,+BAA+B,GAAG,gBAAgB,GAAG,2BAA2B,GAAG,gBAAgB,GAAG,2BAA2B,GAAG,aAAa,GAAG,wBAAwB,GAAG,IAAI;aACtR;SACD,CAAC;QAEF,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,eAAe;gBAC5B,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,4BAA4B;gBACzC,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,wEAAwE;aACrF;YAED;gBACC,WAAW,EAAE,OAAO;gBACpB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,aAAa;gBACtB,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,yDAAyD;aACtE;YACD;gBACC,WAAW,EAAE,WAAW;gBACxB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,uDAAuD;aACpE;YACD;gBACC,WAAW,EAAE,eAAe;gBAC5B,IAAI,EAAE,cAAc;gBACpB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,mCAAmC;aAChD;YACD;gBACC,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,wCAAwC;aACrD;YACD;gBACC,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,+BAA+B;aAC5C;SACD,CAAC;IACH,CAAC;CAAA;AA3ED,kCA2EC"}
@@ -1,13 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
2
- <defs>
3
- <filter id="shadow-dark" x="-20%" y="-20%" width="140%" height="140%">
4
- <feDropShadow dx="-25" dy="25" stdDeviation="15" flood-color="#1a2530" flood-opacity="0.8"/>
5
- </filter>
6
- </defs>
7
-
8
- <g filter="url(#shadow-dark)">
9
- <rect x="32" y="32" width="448" height="448" rx="64" ry="64" fill="#2d3e50"/>
10
-
11
- <path d="M372,256c0,70.1-50.2,127.3-116.5,127.3S139,326.1,139,256s50.2-127.3,116.5-127.3S372,185.9,372,256ZM193.3,256c0,44,31.2,77.3,69.2,77.3s69.2-33.3,69.2-77.3-31.2-77.3-69.2-77.3S193.3,212,193.3,256Z" fill="#ffffff"/>
12
- </g>
13
- </svg>
@@ -1,13 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512">
2
- <defs>
3
- <filter id="shadow" x="-20%" y="-20%" width="140%" height="140%">
4
- <feDropShadow dx="-25" dy="25" stdDeviation="10" flood-color="#ddd" flood-opacity="0.7"/>
5
- </filter>
6
- </defs>
7
-
8
- <g filter="url(#shadow)">
9
- <rect x="32" y="32" width="448" height="448" rx="64" ry="64" fill="#ffffff"/>
10
-
11
- <path d="M372,256c0,70.1-50.2,127.3-116.5,127.3S139,326.1,139,256s50.2-127.3,116.5-127.3S372,185.9,372,256ZM193.3,256c0,44,31.2,77.3,69.2,77.3s69.2-33.3,69.2-77.3-31.2-77.3-69.2-77.3S193.3,212,193.3,256Z" fill="#ff4c15"/>
12
- </g>
13
- </svg>
@@ -1,6 +0,0 @@
1
- import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
- export declare class Runrunit implements INodeType {
3
- description: INodeTypeDescription;
4
- methods: INodeType['methods'];
5
- execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
6
- }
@@ -1,402 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Runrunit = void 0;
4
- const n8n_workflow_1 = require("n8n-workflow");
5
- const Tasks_1 = require("./resources/Tasks");
6
- const DEFAULT_RAW_TEMPLATES = {
7
- 'Administration/User': {
8
- id: 132,
9
- username: 'teste2@teste.com',
10
- realname: 'Teste inclusão',
11
- firstname: 'Teste',
12
- password: '123456',
13
- password2: '123456',
14
- phone: '',
15
- phone2: '',
16
- mobile: '',
17
- emails: [{ email: 'teste1@teste.com', is_default: true, is_dynamic: true }],
18
- comment: 'string',
19
- is_active: true,
20
- is_deleted: false,
21
- picture: null,
22
- date_password_change: '2024-08-07T04:46:21+00:00',
23
- authtype: 1,
24
- last_login: '2026-03-06T12:16:33+00:00',
25
- location: { id: 0 },
26
- default_profile: { id: 1 },
27
- default_entity: { id: 0, name: 'Entidade raiz' },
28
- },
29
- Tasks: {
30
- name: 'Teste000000',
31
- comment: '',
32
- contact: 'Teste CONTACT',
33
- contact_num: null,
34
- serial: 'TESTE0001',
35
- otherserial: null,
36
- is_deleted: false,
37
- status: { id: 1, name: 'ATIVO' },
38
- location: { id: 1, name: 'YESHGRU' },
39
- entity: { id: 0, name: 'Entidade raiz', completename: 'Entidade raiz' },
40
- type: { id: 1, name: 'Notebook' },
41
- manufacturer: { id: 87, name: 'Acer' },
42
- model: { id: 4, name: 'TESTE' },
43
- user: { id: 167, name: 'Teste' },
44
- user_tech: null,
45
- group: [],
46
- group_tech: [],
47
- network: { id: 1, name: 'Sala dos Leões GRU' },
48
- autoupdatesystem: { id: 1, name: 'Runrun.it Native Inventory' },
49
- },
50
- };
51
- function isEmptyObject(obj) {
52
- if (obj === null || obj === undefined)
53
- return true;
54
- if (typeof obj === 'object' && !Array.isArray(obj)) {
55
- try {
56
- return Object.keys(obj).length === 0;
57
- }
58
- catch {
59
- return true;
60
- }
61
- }
62
- return false;
63
- }
64
- function buildBaseUrl(host) {
65
- let baseUrl = (host || '').trim();
66
- if (baseUrl.length === 0)
67
- return '';
68
- if (!/^https?:\/\//i.test(baseUrl)) {
69
- baseUrl = `https://${baseUrl}`;
70
- }
71
- try {
72
- const originMatch = baseUrl.match(/^(https?:\/\/[^\/]+)/i);
73
- const origin = originMatch ? originMatch[1] : '';
74
- const apiMatch = baseUrl.match(/\/(?:apirest|api)\.php/i);
75
- if (origin) {
76
- if (apiMatch) {
77
- return `${origin}${apiMatch[0]}`;
78
- }
79
- return `${origin}/api.php`;
80
- }
81
- baseUrl = baseUrl.replace(/\/apirest\.php\/?/i, '');
82
- baseUrl = baseUrl.replace(/\/+$/g, '');
83
- if (!baseUrl.endsWith('/api.php')) {
84
- baseUrl = `${baseUrl}/api.php`;
85
- }
86
- return baseUrl;
87
- }
88
- catch (e) {
89
- baseUrl = baseUrl.replace(/\/apirest\.php\/?/i, '');
90
- baseUrl = baseUrl.replace(/\/+$/g, '');
91
- if (!baseUrl.endsWith('/api.php')) {
92
- baseUrl = `${baseUrl}/api.php`;
93
- }
94
- return baseUrl;
95
- }
96
- }
97
- async function getOAuthToken(baseUrl, clientId, clientSecret, username, password, scope, authorizationCode, redirectUri) {
98
- try {
99
- const body = authorizationCode
100
- ? {
101
- grant_type: 'authorization_code',
102
- client_id: clientId,
103
- client_secret: clientSecret,
104
- code: authorizationCode,
105
- redirect_uri: redirectUri,
106
- }
107
- : {
108
- grant_type: 'password',
109
- client_id: clientId,
110
- client_secret: clientSecret,
111
- username,
112
- password,
113
- scope,
114
- };
115
- const response = await this.helpers.httpRequest({
116
- method: 'POST',
117
- url: `${baseUrl}/token`,
118
- headers: {
119
- 'Content-Type': 'application/json',
120
- },
121
- body,
122
- json: true,
123
- });
124
- const token = (response === null || response === void 0 ? void 0 : response.session_token) || (response === null || response === void 0 ? void 0 : response.access_token);
125
- if (!token) {
126
- throw new n8n_workflow_1.ApplicationError('Failed to login to Runrun.it: session_token/access_token not found in response', {
127
- level: 'warning',
128
- });
129
- }
130
- return token;
131
- }
132
- catch (error) {
133
- if (error && typeof error === 'object' && 'response' in error) {
134
- const httpError = error;
135
- throw new n8n_workflow_1.ApplicationError(`Failed to login to Runrun.it: ${httpError.response.status} ${httpError.response.statusText}. Check your credentials and URL.`, { level: 'error' });
136
- }
137
- const errorMessage = error instanceof Error ? error.message : String(error);
138
- throw new n8n_workflow_1.ApplicationError(`Failed to login to Runrun.it: ${errorMessage}`, { level: 'error' });
139
- }
140
- }
141
- class Runrunit {
142
- constructor() {
143
- this.description = {
144
- displayName: 'Runrun.it API (Fork)',
145
- name: 'runrunit',
146
- icon: 'file:runrunit.svg',
147
- group: ['transform'],
148
- version: 1,
149
- subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
150
- description: 'Runrun.it API Node compatible with Runrun.it REST API.',
151
- defaults: {
152
- name: 'Runrun.it API',
153
- },
154
- inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
155
- outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
156
- usableAsTool: true,
157
- credentials: [{ name: 'runrunitApi', required: true }],
158
- properties: [
159
- {
160
- displayName: 'Resource',
161
- name: 'resource',
162
- type: 'options',
163
- noDataExpression: true,
164
- options: [{ name: 'Tasks', value: 'Tasks' }],
165
- default: 'Tasks',
166
- },
167
- {
168
- displayName: 'Show Credentials Only',
169
- name: 'showCredentials',
170
- type: 'boolean',
171
- default: false,
172
- description: 'If enabled, the node will output the configured credentials and skip any API requests.',
173
- },
174
- ...Tasks_1.TasksDescription,
175
- ],
176
- };
177
- this.methods = {};
178
- }
179
- async execute() {
180
- const items = this.getInputData();
181
- const returnData = [];
182
- const creds = await this.getCredentials('runrunitApi');
183
- const baseUrl = buildBaseUrl(creds.host);
184
- for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
185
- try {
186
- const operation = this.getNodeParameter('operation', itemIndex);
187
- let itemtype = this.getNodeParameter('itemtype', itemIndex) || 'Tasks';
188
- if (itemtype && !itemtype.includes('/'))
189
- itemtype = `Tasks/${itemtype}`;
190
- const returnAll = this.getNodeParameter('returnAll', itemIndex, true);
191
- let token = '';
192
- try {
193
- token = await getOAuthToken.call(this, baseUrl, creds.clientId, creds.clientSecret, creds.username, creds.password, creds.scope || undefined, creds.useAuthorizationCode
194
- ? creds.authorizationCode
195
- : undefined, creds.redirectUri || undefined);
196
- }
197
- catch (err) {
198
- if (this.continueOnFail()) {
199
- returnData.push({
200
- json: { error: err instanceof Error ? err.message : String(err) },
201
- pairedItem: { item: itemIndex },
202
- });
203
- continue;
204
- }
205
- throw err;
206
- }
207
- const headers = { Authorization: `Bearer ${token}` };
208
- let options;
209
- if (operation === 'get') {
210
- const id = this.getNodeParameter('itemid', itemIndex, '');
211
- let url = `${baseUrl}/${itemtype}${id ? '/' + id : ''}`;
212
- if (!id && returnAll === false) {
213
- const params = [];
214
- const limit = this.getNodeParameter('limit', itemIndex, 10);
215
- params.push(`limit=${limit}`);
216
- const filtersParam = this.getNodeParameter('filters', itemIndex, {});
217
- const filterStr = (filtersParam && filtersParam.filter) || '';
218
- if (filterStr)
219
- params.push(`filter=${encodeURIComponent(filterStr)}`);
220
- if (params.length)
221
- url += (url.includes('?') ? '&' : '?') + params.join('&');
222
- }
223
- options = { method: 'GET', url, headers, json: true };
224
- }
225
- else if (operation === 'create') {
226
- const rawInputParam = this.getNodeParameter('input', itemIndex, {});
227
- let rawInput = rawInputParam;
228
- if (typeof rawInputParam === 'string') {
229
- try {
230
- rawInput = JSON.parse(rawInputParam);
231
- }
232
- catch (e) {
233
- if (this.continueOnFail()) {
234
- returnData.push({
235
- json: { error: 'Invalid JSON in Input (raw)' },
236
- pairedItem: { item: itemIndex },
237
- });
238
- continue;
239
- }
240
- throw new n8n_workflow_1.ApplicationError('Invalid JSON in Input (raw)', { level: 'error' });
241
- }
242
- }
243
- const sendRawBody = this.getNodeParameter('sendRawBody', itemIndex, true);
244
- if (sendRawBody && isEmptyObject(rawInput)) {
245
- if (sendRawBody && DEFAULT_RAW_TEMPLATES['Tasks']) {
246
- rawInput = DEFAULT_RAW_TEMPLATES['Tasks'];
247
- }
248
- else {
249
- if (this.continueOnFail()) {
250
- returnData.push({
251
- json: { error: 'Input (raw) is required when creating Tasks' },
252
- pairedItem: { item: itemIndex },
253
- });
254
- continue;
255
- }
256
- throw new n8n_workflow_1.ApplicationError('Input (raw) is required when creating Tasks', {
257
- level: 'error',
258
- });
259
- }
260
- }
261
- const bodyToSend = sendRawBody && !isEmptyObject(rawInput) ? rawInput : { input: rawInput };
262
- options = {
263
- method: 'POST',
264
- url: `${baseUrl}/${itemtype}`,
265
- headers,
266
- body: bodyToSend,
267
- json: true,
268
- };
269
- }
270
- else if (operation === 'update') {
271
- const id = this.getNodeParameter('itemid', itemIndex);
272
- const idValue = id;
273
- const idNum = typeof idValue === 'string'
274
- ? idValue === ''
275
- ? NaN
276
- : Number(idValue)
277
- : Number(idValue);
278
- if (!idValue || Number.isNaN(idNum) || idNum === 0) {
279
- if (this.continueOnFail()) {
280
- returnData.push({
281
- json: {
282
- error: 'Item ID (itemid) is required and must be a positive number for update operations',
283
- },
284
- pairedItem: { item: itemIndex },
285
- });
286
- continue;
287
- }
288
- throw new n8n_workflow_1.ApplicationError('Item ID (itemid) is required and must be a positive number for update operations', { level: 'error' });
289
- }
290
- const rawInputParam = this.getNodeParameter('input', itemIndex, {});
291
- let rawInput = rawInputParam;
292
- if (typeof rawInputParam === 'string') {
293
- try {
294
- rawInput = JSON.parse(rawInputParam);
295
- }
296
- catch (e) {
297
- if (this.continueOnFail()) {
298
- returnData.push({
299
- json: { error: 'Invalid JSON in Input (raw)' },
300
- pairedItem: { item: itemIndex },
301
- });
302
- continue;
303
- }
304
- throw new n8n_workflow_1.ApplicationError('Invalid JSON in Input (raw)', { level: 'error' });
305
- }
306
- }
307
- const sendRawBody = this.getNodeParameter('sendRawBody', itemIndex, true);
308
- if (sendRawBody && isEmptyObject(rawInput)) {
309
- if (DEFAULT_RAW_TEMPLATES['Tasks'])
310
- rawInput = DEFAULT_RAW_TEMPLATES['Tasks'];
311
- }
312
- const bodyToSend = sendRawBody && !isEmptyObject(rawInput) ? rawInput : { input: rawInput };
313
- options = {
314
- method: 'PATCH',
315
- url: `${baseUrl}/${itemtype}/${id}`,
316
- headers,
317
- body: bodyToSend,
318
- json: true,
319
- };
320
- }
321
- else if (operation === 'delete') {
322
- const id = this.getNodeParameter('itemid', itemIndex);
323
- const idValueDel = id;
324
- const idNumDel = typeof idValueDel === 'string'
325
- ? idValueDel === ''
326
- ? NaN
327
- : Number(idValueDel)
328
- : Number(idValueDel);
329
- if (!idValueDel || Number.isNaN(idNumDel) || idNumDel === 0) {
330
- if (this.continueOnFail()) {
331
- returnData.push({
332
- json: {
333
- error: 'Item ID (itemid) is required and must be a positive number for delete operations',
334
- },
335
- pairedItem: { item: itemIndex },
336
- });
337
- continue;
338
- }
339
- throw new n8n_workflow_1.ApplicationError('Item ID (itemid) is required and must be a positive number for delete operations', { level: 'error' });
340
- }
341
- options = {
342
- method: 'DELETE',
343
- url: `${baseUrl}/${itemtype}/${id}`,
344
- headers,
345
- json: true,
346
- };
347
- }
348
- else {
349
- throw new n8n_workflow_1.ApplicationError(`Unknown operation: ${operation}`, { level: 'warning' });
350
- }
351
- const showCredentials = this.getNodeParameter('showCredentials', itemIndex, false);
352
- if (options && options.body !== undefined) {
353
- options.headers = { ...(options.headers || {}), 'Content-Type': 'application/json' };
354
- }
355
- if (showCredentials) {
356
- returnData.push({
357
- json: {
358
- host: creds.host,
359
- baseUrl,
360
- clientId: creds.clientId,
361
- clientSecret: creds.clientSecret,
362
- username: creds.username,
363
- password: creds.password,
364
- scope: creds.scope,
365
- },
366
- pairedItem: { item: itemIndex },
367
- });
368
- }
369
- else {
370
- const response = await this.helpers.httpRequest(options);
371
- if (Array.isArray(response)) {
372
- let outputArray = response;
373
- if (returnAll === false) {
374
- const limit = this.getNodeParameter('limit', itemIndex, 10);
375
- outputArray = outputArray.slice(0, limit);
376
- }
377
- for (const resItem of outputArray) {
378
- returnData.push({ json: resItem, pairedItem: { item: itemIndex } });
379
- }
380
- }
381
- else {
382
- returnData.push({ json: response, pairedItem: { item: itemIndex } });
383
- }
384
- }
385
- }
386
- catch (error) {
387
- if (this.continueOnFail()) {
388
- returnData.push({
389
- json: { error: error instanceof Error ? error.message : String(error) },
390
- pairedItem: { item: itemIndex },
391
- });
392
- }
393
- else {
394
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex });
395
- }
396
- }
397
- }
398
- return returnData.length ? [returnData] : [];
399
- }
400
- }
401
- exports.Runrunit = Runrunit;
402
- //# sourceMappingURL=RunrunitApi.node.js.map