@atom8n/n8n-node-dev 2.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.
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Build = void 0;
4
+ const di_1 = require("@n8n/di");
5
+ const core_1 = require("@oclif/core");
6
+ const n8n_core_1 = require("n8n-core");
7
+ const src_1 = require("../src");
8
+ class Build extends core_1.Command {
9
+ async run() {
10
+ const { flags } = await this.parse(Build);
11
+ this.log('\nBuild credentials and nodes');
12
+ this.log('=========================');
13
+ try {
14
+ const options = {};
15
+ if (flags.destination) {
16
+ options.destinationFolder = flags.destination;
17
+ }
18
+ if (flags.watch) {
19
+ options.watch = true;
20
+ }
21
+ const outputDirectory = await (0, src_1.buildFiles)(options);
22
+ this.log(`The nodes got built and saved into the following folder:\n${outputDirectory}`);
23
+ }
24
+ catch (error) {
25
+ this.log(`\nGOT ERROR: "${error.message}"`);
26
+ this.log('====================================');
27
+ this.log(error.stack);
28
+ }
29
+ }
30
+ }
31
+ exports.Build = Build;
32
+ Build.description = 'Builds credentials and nodes and copies it to n8n custom extension folder';
33
+ Build.examples = [
34
+ '$ n8n-node-dev build',
35
+ '$ n8n-node-dev build --destination ~/n8n-nodes',
36
+ '$ n8n-node-dev build --watch',
37
+ ];
38
+ Build.flags = {
39
+ help: core_1.Flags.help({ char: 'h' }),
40
+ destination: core_1.Flags.string({
41
+ char: 'd',
42
+ description: `The path to copy the compiled files to [default: ${di_1.Container.get(n8n_core_1.InstanceSettings).customExtensionDir}]`,
43
+ }),
44
+ watch: core_1.Flags.boolean({
45
+ description: 'Starts in watch mode and automatically builds and copies file whenever they change',
46
+ }),
47
+ };
48
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../commands/build.ts"],"names":[],"mappings":";;;AAAA,gCAAoC;AACpC,sCAA6C;AAC7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ACZ,cAAS,CAAC,GAAG,CAAC,2BAAgB,CAAC,CAAC,kBACjC,GAAG;KACH,CAAC;IACF,KAAK,EAAE,YAAK,CAAC,OAAO,CAAC;QACpB,WAAW,EACV,oFAAoF;KACrF,CAAC;CACF,CAAC"}
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.New = void 0;
37
+ const core_1 = require("@oclif/core");
38
+ const changeCase = __importStar(require("change-case"));
39
+ const promises_1 = require("fs/promises");
40
+ const inquirer = __importStar(require("inquirer"));
41
+ const path_1 = require("path");
42
+ const src_1 = require("../src");
43
+ class New extends core_1.Command {
44
+ async run() {
45
+ try {
46
+ this.log('\nCreate new credentials/node');
47
+ this.log('=========================');
48
+ const typeQuestion = {
49
+ name: 'type',
50
+ type: 'list',
51
+ default: 'Node',
52
+ message: 'What do you want to create?',
53
+ choices: ['Credentials', 'Node'],
54
+ };
55
+ const typeAnswers = await inquirer.prompt(typeQuestion);
56
+ let sourceFolder = '';
57
+ const sourceFileName = 'simple.ts';
58
+ let defaultName = '';
59
+ let getDescription = false;
60
+ if (typeAnswers.type === 'Node') {
61
+ getDescription = true;
62
+ const nodeTypeQuestion = {
63
+ name: 'nodeType',
64
+ type: 'list',
65
+ default: 'Execute',
66
+ message: 'What kind of node do you want to create?',
67
+ choices: ['Execute', 'Trigger', 'Webhook'],
68
+ };
69
+ const nodeTypeAnswers = await inquirer.prompt(nodeTypeQuestion);
70
+ sourceFolder = 'execute';
71
+ defaultName = 'My Node';
72
+ if (nodeTypeAnswers.nodeType === 'Trigger') {
73
+ sourceFolder = 'trigger';
74
+ defaultName = 'My Trigger';
75
+ }
76
+ else if (nodeTypeAnswers.nodeType === 'Webhook') {
77
+ sourceFolder = 'webhook';
78
+ defaultName = 'My Webhook';
79
+ }
80
+ }
81
+ else {
82
+ sourceFolder = 'credentials';
83
+ defaultName = 'My Service API';
84
+ }
85
+ const additionalQuestions = [
86
+ {
87
+ name: 'name',
88
+ type: 'input',
89
+ default: defaultName,
90
+ message: 'How should the node be called?',
91
+ },
92
+ ];
93
+ if (getDescription) {
94
+ additionalQuestions.push({
95
+ name: 'description',
96
+ type: 'input',
97
+ default: 'Node converts input data to chocolate',
98
+ message: 'What should the node description be?',
99
+ });
100
+ }
101
+ const additionalAnswers = await inquirer.prompt(additionalQuestions);
102
+ const nodeName = additionalAnswers.name;
103
+ const destinationFilePath = (0, path_1.join)(process.cwd(), `${changeCase.pascalCase(nodeName)}.${typeAnswers.type.toLowerCase()}.ts`);
104
+ const sourceFilePath = (0, path_1.join)(__dirname, '../../templates', sourceFolder, sourceFileName);
105
+ try {
106
+ await (0, promises_1.access)(destinationFilePath);
107
+ const overwriteQuestion = [
108
+ {
109
+ name: 'overwrite',
110
+ type: 'confirm',
111
+ default: false,
112
+ message: `The file "${destinationFilePath}" already exists and would be overwritten. Do you want to proceed and overwrite the file?`,
113
+ },
114
+ ];
115
+ const overwriteAnswers = await inquirer.prompt(overwriteQuestion);
116
+ if (overwriteAnswers.overwrite === false) {
117
+ this.log('\nNode creation got canceled!');
118
+ return;
119
+ }
120
+ }
121
+ catch (error) {
122
+ }
123
+ const replaceValues = {
124
+ ClassNameReplace: changeCase.pascalCase(nodeName),
125
+ DisplayNameReplace: changeCase.capitalCase(nodeName),
126
+ N8nNameReplace: changeCase.camelCase(nodeName),
127
+ NodeDescriptionReplace: additionalAnswers.description,
128
+ };
129
+ await (0, src_1.createTemplate)(sourceFilePath, destinationFilePath, replaceValues);
130
+ this.log('\nExecution was successful:');
131
+ this.log('====================================');
132
+ this.log(`Node got created: ${destinationFilePath}`);
133
+ }
134
+ catch (error) {
135
+ this.log(`\nGOT ERROR: "${error.message}"`);
136
+ this.log('====================================');
137
+ this.log(error.stack);
138
+ }
139
+ }
140
+ }
141
+ exports.New = New;
142
+ New.description = 'Create new credentials/node';
143
+ New.examples = ['$ n8n-node-dev new'];
144
+ //# sourceMappingURL=new.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new.js","sourceRoot":"","sources":["../../commands/new.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,sCAAsC;AACtC,wDAA0C;AAC1C,0CAAqC;AACrC,mDAAqC;AACrC,+BAA4B;AAE5B,gCAAwC;AAExC,MAAa,GAAI,SAAQ,cAAO;IAK/B,KAAK,CAAC,GAAG;QACR,IAAI,CAAC;YACJ,IAAI,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;YAC1C,IAAI,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;YAGtC,MAAM,YAAY,GAAgC;gBACjD,IAAI,EAAE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a,GAAG;gBACrB,gBAAgB,EAAE,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC;gBACjD,kBAAkB,EAAE,UAAU,CAAC,WAAW,CAAC,QAAQ,CAAC;gBACpD,cAAc,EAAE,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC;gBAC9C,sBAAsB,EAAE,iBAAiB,CAAC,WAAW;aACrD,CAAC;YAEF,MAAM,IAAA,oBAAc,EAAC,cAAc,EAAE,mBAAmB,EAAE,aAAa,CAAC,CAAC;YAEzE,IAAI,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;YACxC,IAAI,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;YAEjD,IAAI,CAAC,GAAG,CAAC,qBAAqB,mBAAmB,EAAE,CAAC,CAAC;QACtD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAEhB,IAAI,CAAC,GAAG,CAAC,iBAAiB,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;YAC5C,IAAI,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;YAEjD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;IACF,CAAC;;AA9IF,kBA+IC;AA9IO,eAAW,GAAG,6BAA6B,CAAC;AAE5C,YAAQ,GAAG,CAAC,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createCustomTsconfig = createCustomTsconfig;
7
+ exports.buildFiles = buildFiles;
8
+ const di_1 = require("@n8n/di");
9
+ const child_process_1 = require("child_process");
10
+ const fast_glob_1 = __importDefault(require("fast-glob"));
11
+ const promises_1 = require("fs/promises");
12
+ const n8n_core_1 = require("n8n-core");
13
+ const n8n_workflow_1 = require("n8n-workflow");
14
+ const path_1 = require("path");
15
+ const tmp_promise_1 = require("tmp-promise");
16
+ async function createCustomTsconfig() {
17
+ const tsconfigPath = (0, path_1.join)((0, path_1.dirname)(require.resolve('n8n-node-dev/src')), 'tsconfig-build.json');
18
+ const tsConfigString = await (0, promises_1.readFile)(tsconfigPath, { encoding: 'utf8' });
19
+ const tsConfig = (0, n8n_workflow_1.jsonParse)(tsConfigString);
20
+ const newIncludeFiles = [];
21
+ for (const includeFile of tsConfig.include) {
22
+ newIncludeFiles.push((0, path_1.join)(process.cwd(), includeFile));
23
+ }
24
+ tsConfig.include = newIncludeFiles;
25
+ const { path, cleanup } = await (0, tmp_promise_1.file)();
26
+ await (0, promises_1.writeFile)(path, JSON.stringify(tsConfig, null, 2));
27
+ return {
28
+ path,
29
+ cleanup,
30
+ };
31
+ }
32
+ async function buildFiles({ destinationFolder = di_1.Container.get(n8n_core_1.InstanceSettings).customExtensionDir, watch, }) {
33
+ const tscPath = (0, path_1.join)((0, path_1.dirname)(require.resolve('typescript')), 'tsc');
34
+ const tsconfigData = await createCustomTsconfig();
35
+ await Promise.all(['*.svg', '*.png', '*.node.json'].map(async (filenamePattern) => {
36
+ const files = await (0, fast_glob_1.default)(`**/${filenamePattern}`);
37
+ for (const file of files) {
38
+ const src = (0, path_1.resolve)(process.cwd(), file);
39
+ const dest = (0, path_1.resolve)(destinationFolder, file);
40
+ await (0, promises_1.mkdir)((0, path_1.dirname)(dest), { recursive: true });
41
+ await (0, promises_1.copyFile)(src, dest);
42
+ }
43
+ }));
44
+ const nodeModulesPath = (0, path_1.join)(__dirname, '../../node_modules/');
45
+ let buildCommand = `${tscPath} --p ${tsconfigData.path} --outDir ${destinationFolder} --rootDir ${process.cwd()} --baseUrl ${nodeModulesPath}`;
46
+ if (watch) {
47
+ buildCommand += ' --watch';
48
+ }
49
+ try {
50
+ const buildProcess = (0, child_process_1.spawn)('node', buildCommand.split(' '), {
51
+ windowsVerbatimArguments: true,
52
+ cwd: process.cwd(),
53
+ });
54
+ buildProcess.stdout.pipe(process.stdout);
55
+ buildProcess.stderr.pipe(process.stderr);
56
+ process.on('exit', () => buildProcess.kill());
57
+ await new Promise((resolve) => {
58
+ buildProcess.on('exit', resolve);
59
+ });
60
+ }
61
+ catch (error) {
62
+ let errorMessage = error.message;
63
+ if (error.stdout !== undefined) {
64
+ errorMessage = `${errorMessage}\nGot following output:\n${error.stdout}`;
65
+ }
66
+ throw new Error(errorMessage);
67
+ }
68
+ finally {
69
+ await tsconfigData.cleanup();
70
+ }
71
+ return destinationFolder;
72
+ }
73
+ //# sourceMappingURL=Build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Build.js","sourceRoot":"","sources":["../../src/Build.ts"],"names":[],"mappings":";;;;;AAmBA,oDAyBC;AAOD,gCA6DC;AA9GD,gCAAoC;AACpC,iDAAsC;AACtC,0DAA6B;AAC7B,0CAAmE;AACnE,uCAA4C;AAC5C,+CAAyC;AACzC,+BAA6D;AAC7D,6CAA8C;AAUvC,KAAK,UAAU,oBAAoB;IAEzC,MAAM,YAAY,GAAG,IAAA,WAAI,EAAC,IAAA,cAAO,EAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC;IAG/F,MAAM,cAAc,GAAG,MAAM,IAAA,mBAAQ,EAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAE1E,MAAM,QAAQ,GAAG,IAAA,wBAAS,EAAwB,cAAc,CAAC,CAAC;IAGlE,MAAM,eAAe,GAAG,EAAE,CAAC;IAE3B,KAAK,MAAM,WAAW,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QAC5C,eAAe,CAAC,IAAI,CAAC,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC;IACxD,CAAC;IACD,QAAQ,CAAC,OAAO,GAAG,eAAe,CAAC;IAGnC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,k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createTemplate;
4
+ const promises_1 = require("fs/promises");
5
+ const replace_in_file_1 = require("replace-in-file");
6
+ async function createTemplate(sourceFilePath, destinationFilePath, replaceValues) {
7
+ await (0, promises_1.copyFile)(sourceFilePath, destinationFilePath);
8
+ const options = {
9
+ files: [destinationFilePath],
10
+ from: [],
11
+ to: [],
12
+ };
13
+ options.from = Object.keys(replaceValues).map((key) => {
14
+ return new RegExp(key, 'g');
15
+ });
16
+ options.to = Object.values(replaceValues);
17
+ await (0, replace_in_file_1.replaceInFile)(options);
18
+ }
19
+ //# sourceMappingURL=Create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Create.js","sourceRoot":"","sources":["../../src/Create.ts"],"names":[],"mappings":";;AAWA,wCAoBC;AA/BD,0CAAuC;AAEvC,qDAAgD;AASzC,KAAK,UAAU,cAAc,CACnC,cAAsB,EACtB,mBAA2B,EAC3B,aAAqB;IAIrB,MAAM,IAAA,mBAAQ,EAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC;IAGpD,MAAM,OAAO,GAAwB;QACpC,KAAK,EAAE,CAAC,mBAAmB,CAAC;QAC5B,IAAI,EAAE,EAAE;QACR,EAAE,EAAE,EAAE;KACN,CAAC;IACF,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACrD,OAAO,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAC1C,MAAM,IAAA,+BAAa,EAAC,OAAO,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Interfaces.js","sourceRoot":"","sources":["../../src/Interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Build"), exports);
18
+ __exportStar(require("./Create"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@atom8n/n8n-node-dev",
3
+ "version": "2.2.0",
4
+ "description": "CLI to simplify n8n credentials/node development",
5
+ "main": "dist/src/index",
6
+ "types": "dist/src/index.d.ts",
7
+ "oclif": {
8
+ "commands": "./dist/commands",
9
+ "bin": "n8n-node-dev"
10
+ },
11
+ "scripts": {
12
+ "clean": "rimraf dist .turbo",
13
+ "dev": "pnpm watch",
14
+ "build": "tsc --noEmit",
15
+ "build-node-dev": "tsc",
16
+ "format": "biome format --write .",
17
+ "format:check": "biome ci .",
18
+ "lint": "eslint src --quiet",
19
+ "lint:fix": "eslint src --fix",
20
+ "prepack": "echo \"Building project...\" && rm -rf dist && tsc -b",
21
+ "watch": "tsc --watch"
22
+ },
23
+ "bin": {
24
+ "n8n-node-dev": "./bin/n8n-node-dev"
25
+ },
26
+ "keywords": [
27
+ "development",
28
+ "node",
29
+ "helper",
30
+ "n8n"
31
+ ],
32
+ "files": [
33
+ "bin",
34
+ "dist",
35
+ "templates",
36
+ "src/tsconfig-build.json"
37
+ ],
38
+ "devDependencies": {
39
+ "@atom8n/typescript-config": "1.3.0",
40
+ "@types/inquirer": "^6.5.0"
41
+ },
42
+ "dependencies": {
43
+ "@atom8n/di": "0.10.0",
44
+ "@oclif/core": "4.0.7",
45
+ "change-case": "^4.1.1",
46
+ "fast-glob": "catalog:",
47
+ "inquirer": "^7.0.1",
48
+ "@atom8n/n8n-core": "2.2.0",
49
+ "@atom8n/n8n-workflow": "2.2.0",
50
+ "replace-in-file": "^6.0.0",
51
+ "tmp-promise": "^3.0.3"
52
+ }
53
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "strict": true,
4
+ "module": "commonjs",
5
+ "moduleResolution": "node",
6
+ "target": "es2021",
7
+ "lib": ["es2021"],
8
+ "importHelpers": true,
9
+ "esModuleInterop": true,
10
+ "declaration": true,
11
+ "incremental": true,
12
+ "sourceMap": true
13
+ },
14
+ "include": ["**/*.credentials.ts", "**/*.node.ts"]
15
+ }
@@ -0,0 +1,25 @@
1
+ import { ICredentialType, NodePropertyTypes, INodeProperties } from 'n8n-workflow';
2
+
3
+ export class ClassNameReplace implements ICredentialType {
4
+ name = 'N8nNameReplace';
5
+
6
+ displayName = 'DisplayNameReplace';
7
+
8
+ properties: INodeProperties[] = [
9
+ // The credentials to get from user and save encrypted.
10
+ // Properties can be defined exactly in the same way
11
+ // as node properties.
12
+ {
13
+ displayName: 'User',
14
+ name: 'user',
15
+ type: 'string',
16
+ default: '',
17
+ },
18
+ {
19
+ displayName: 'Access Token',
20
+ name: 'accessToken',
21
+ type: 'string',
22
+ default: '',
23
+ },
24
+ ];
25
+ }
@@ -0,0 +1,53 @@
1
+ import {
2
+ IExecuteFunctions,
3
+ INodeExecutionData,
4
+ INodeType,
5
+ INodeTypeDescription,
6
+ } from 'n8n-workflow';
7
+
8
+ export class ClassNameReplace implements INodeType {
9
+ description: INodeTypeDescription = {
10
+ displayName: 'DisplayNameReplace',
11
+ name: 'N8nNameReplace',
12
+ group: ['transform'],
13
+ version: 1,
14
+ description: 'NodeDescriptionReplace',
15
+ defaults: {
16
+ name: 'DisplayNameReplace',
17
+ color: '#772244',
18
+ },
19
+ inputs: ['main'],
20
+ outputs: ['main'],
21
+ properties: [
22
+ // Node properties which the user gets displayed and
23
+ // can change on the node.
24
+ {
25
+ displayName: 'My String',
26
+ name: 'myString',
27
+ type: 'string',
28
+ default: '',
29
+ placeholder: 'Placeholder value',
30
+ description: 'The description text',
31
+ },
32
+ ],
33
+ };
34
+
35
+ async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
36
+ const items = this.getInputData();
37
+
38
+ let item: INodeExecutionData;
39
+ let myString: string;
40
+
41
+ // Iterates over all input items and add the key "myString" with the
42
+ // value the parameter "myString" resolves to.
43
+ // (This could be a different value for each item in case it contains an expression)
44
+ for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
45
+ myString = this.getNodeParameter('myString', itemIndex, '') as string;
46
+ item = items[itemIndex];
47
+
48
+ item.json.myString = myString;
49
+ }
50
+
51
+ return [items];
52
+ }
53
+ }
@@ -0,0 +1,74 @@
1
+ import { ITriggerFunctions, INodeType, INodeTypeDescription, ITriggerResponse } from 'n8n-workflow';
2
+
3
+ export class ClassNameReplace implements INodeType {
4
+ description: INodeTypeDescription = {
5
+ displayName: 'DisplayNameReplace',
6
+ name: 'N8nNameReplace',
7
+ group: ['trigger'],
8
+ version: 1,
9
+ description: 'NodeDescriptionReplace',
10
+ defaults: {
11
+ name: 'DisplayNameReplace',
12
+ color: '#00FF00',
13
+ },
14
+ inputs: [],
15
+ outputs: ['main'],
16
+ properties: [
17
+ // Node properties which the user gets displayed and
18
+ // can change on the node.
19
+ {
20
+ displayName: 'Interval',
21
+ name: 'interval',
22
+ type: 'number',
23
+ typeOptions: {
24
+ minValue: 1,
25
+ },
26
+ default: 1,
27
+ description: 'Every how many minutes the workflow should be triggered.',
28
+ },
29
+ ],
30
+ };
31
+
32
+ async trigger(this: ITriggerFunctions): Promise<ITriggerResponse> {
33
+ const interval = this.getNodeParameter('interval', 1) as number;
34
+
35
+ if (interval <= 0) {
36
+ throw new Error('The interval has to be set to at least 1 or higher!');
37
+ }
38
+
39
+ const executeTrigger = () => {
40
+ // Every time the emit function gets called a new workflow
41
+ // executions gets started with the provided entries.
42
+ const entry = {
43
+ exampleKey: 'exampleData',
44
+ };
45
+ this.emit([this.helpers.returnJsonArray([entry])]);
46
+ };
47
+
48
+ // Sets an interval and triggers the workflow all n seconds
49
+ // (depends on what the user selected on the node)
50
+ const intervalValue = interval * 60 * 1000;
51
+ const intervalObj = setInterval(executeTrigger, intervalValue);
52
+
53
+ // The "closeFunction" function gets called by n8n whenever
54
+ // the workflow gets deactivated and can so clean up.
55
+ async function closeFunction() {
56
+ clearInterval(intervalObj);
57
+ }
58
+
59
+ // The "manualTriggerFunction" function gets called by n8n
60
+ // when a user is in the workflow editor and starts the
61
+ // workflow manually. So the function has to make sure that
62
+ // the emit() gets called with similar data like when it
63
+ // would trigger by itself so that the user knows what data
64
+ // to expect.
65
+ async function manualTriggerFunction() {
66
+ executeTrigger();
67
+ }
68
+
69
+ return {
70
+ closeFunction,
71
+ manualTriggerFunction,
72
+ };
73
+ }
74
+ }
@@ -0,0 +1,60 @@
1
+ import {
2
+ IDataObject,
3
+ IWebhookFunctions,
4
+ INodeTypeDescription,
5
+ INodeType,
6
+ IWebhookResponseData,
7
+ } from 'n8n-workflow';
8
+
9
+ export class ClassNameReplace implements INodeType {
10
+ description: INodeTypeDescription = {
11
+ displayName: 'DisplayNameReplace',
12
+ name: 'N8nNameReplace',
13
+ group: ['trigger'],
14
+ version: 1,
15
+ description: 'NodeDescriptionReplace',
16
+ defaults: {
17
+ name: 'DisplayNameReplace',
18
+ color: '#885577',
19
+ },
20
+ inputs: [],
21
+ outputs: ['main'],
22
+ webhooks: [
23
+ {
24
+ name: 'default',
25
+ httpMethod: 'POST',
26
+ responseMode: 'onReceived',
27
+ // Each webhook property can either be hardcoded
28
+ // like the above ones or referenced from a parameter
29
+ // like the "path" property bellow
30
+ path: '={{$parameter["path"]}}',
31
+ },
32
+ ],
33
+ properties: [
34
+ {
35
+ displayName: 'Path',
36
+ name: 'path',
37
+ type: 'string',
38
+ default: '',
39
+ placeholder: '',
40
+ required: true,
41
+ description: 'The path to listen to',
42
+ },
43
+ ],
44
+ };
45
+
46
+ async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
47
+ // The data to return and so start the workflow with
48
+ const returnData: IDataObject[] = [];
49
+ returnData.push({
50
+ headers: this.getHeaderData(),
51
+ params: this.getParamsData(),
52
+ query: this.getQueryData(),
53
+ body: this.getBodyData(),
54
+ });
55
+
56
+ return {
57
+ workflowData: [this.helpers.returnJsonArray(returnData)],
58
+ };
59
+ }
60
+ }