@henry2323/n8n-nodes-calendar-tool-wrapper 0.1.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 ADDED
@@ -0,0 +1,34 @@
1
+ ![Banner image](https://user-images.githubusercontent.com/10284570/173569848-c624317f-42b1-45a6-ab09-f0ea3c247648.png)
2
+
3
+
4
+ # n8n-nodes-run-node-with-credentials-x
5
+
6
+ The node allows you to dynamically set the credentials to be used for a specific node you want to run.
7
+ With this you have to paste in a node you want to use, this can be any node with any parameters set. By then also entering the credentials ID the node is ran with those credentials.
8
+
9
+ > **Warning**
10
+ > You can only use the same type of credentials as the original one set in the node that is pasted in.
11
+ > Be sure to enter credentials, so the node know which credentials need to be replaced. Without credentials set, the node cannot determine the credentialtype name and therefore cannot set it.
12
+
13
+ ![NodeExample](https://github.com/bramkn/n8n-nodes-run-node-with-credentials/blob/master/img/credentialsNodeImg.png)
14
+
15
+ ## Developer
16
+
17
+ Hi,
18
+
19
+ My name is Bram and I am the developer of this node.
20
+ I am an independant consultant and expert partner of n8n.
21
+ My nodes are free to use for everyone, but please consider [donating](https://donate.stripe.com/3cs5oe7xM6L77Yc5ko) when you use my nodes.
22
+ This helps me to build and maintain nodes for everyone to use.
23
+
24
+ If you are looking for some outside help with n8n, I can of course also offer my services.
25
+ * Node Development
26
+ * Workflow Development
27
+ * Mentoring
28
+ * Support
29
+
30
+ Please contact me @ bram@knitco.nl if you want to make use of my services.
31
+
32
+ For questions or issues with nodes, please open an issue on Github.
33
+
34
+
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CalendarToolWrapperX = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const subWorkflowTemplate = require("../../../../n8n-nodes-run-node-with-credentials/nodes/RunNodeWithCredentialsX/subWorkflowTemplate.json");
6
+ class CalendarToolWrapperX {
7
+ constructor() {
8
+ // @ts-ignore - Adding custom aiTool property to type definition
9
+ this.description = {
10
+ displayName: 'Calendar Tool Wrapper X',
11
+ name: 'calendarToolWrapperX',
12
+ icon: 'file:RunKeys.svg',
13
+ group: ['transform'],
14
+ version: 1.1,
15
+ description: 'Wraps Microsoft Calendar Tool for AI operations with credential injection',
16
+ defaults: {
17
+ name: 'Calendar Tool Wrapper X',
18
+ color: '#772244',
19
+ },
20
+ inputs: [{
21
+ type: "main" /* Main */
22
+ }],
23
+ outputs: [{
24
+ type: "main" /* Main */
25
+ },
26
+ {
27
+ type: "main" /* Main */,
28
+ displayName: 'AI Tool'
29
+ }],
30
+ properties: [
31
+ {
32
+ displayName: 'Credentials ID',
33
+ name: 'credentialsId',
34
+ type: 'string',
35
+ default: '',
36
+ required: true,
37
+ description: 'ID of credentials to inject',
38
+ },
39
+ {
40
+ displayName: 'Calendar ID',
41
+ name: 'calendarId',
42
+ type: 'string',
43
+ default: '',
44
+ required: true,
45
+ description: 'Target calendar ID for operations',
46
+ },
47
+ {
48
+ displayName: 'Return All Events',
49
+ name: 'returnAll',
50
+ type: 'boolean',
51
+ default: false,
52
+ description: 'Whether to return all results or only first page',
53
+ }
54
+ ],
55
+ aiTool: {
56
+ name: 'calendarQuery',
57
+ description: 'Query Microsoft Calendar events',
58
+ parametersSchema: require('./calendarTool.schema.json')
59
+ }
60
+ };
61
+ }
62
+ async execute() {
63
+ var _a, _b, _c, _d, _e, _f;
64
+ const items = this.getInputData();
65
+ try {
66
+ const credentialsId = this.getNodeParameter('credentialsId', 0);
67
+ const calendarId = this.getNodeParameter('calendarId', 0);
68
+ const returnAll = this.getNodeParameter('returnAll', 0);
69
+ // Configure calendar tool node
70
+ const calendarNode = {
71
+ type: 'n8n-nodes-base.microsoftOutlookTool',
72
+ typeVersion: 2,
73
+ position: [1000, 340],
74
+ name: 'Microsoft_Calendar_Tool',
75
+ credentials: {
76
+ microsoftOutlookOAuth2Api: {
77
+ id: credentialsId
78
+ }
79
+ },
80
+ parameters: {
81
+ resource: 'calendarEvent',
82
+ operation: 'getAll',
83
+ calendarId,
84
+ returnAll,
85
+ options: {
86
+ fromAllCalendars: false
87
+ }
88
+ }
89
+ };
90
+ // Clone and configure workflow template
91
+ const template = JSON.parse(JSON.stringify(subWorkflowTemplate));
92
+ template.nodes.push(calendarNode);
93
+ // Update connection references
94
+ if ((_d = (_c = (_b = (_a = template.connections) === null || _a === void 0 ? void 0 : _a.Start) === null || _b === void 0 ? void 0 : _b.main) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d[0]) {
95
+ template.connections.Start.main[0][0].node = calendarNode.name;
96
+ }
97
+ // Execute sub-workflow
98
+ const workflowInfo = {
99
+ code: template,
100
+ };
101
+ const executionResult = await this.executeWorkflow(workflowInfo, items);
102
+ // Handle empty results
103
+ if (!((_e = executionResult === null || executionResult === void 0 ? void 0 : executionResult.data) === null || _e === void 0 ? void 0 : _e[0])) {
104
+ return [
105
+ [],
106
+ [{ json: { toolOutput: [] } }] // AI tool output
107
+ ];
108
+ }
109
+ // Format AI tool output
110
+ const toolOutput = executionResult.data[0].map((item) => ({
111
+ eventId: item.json.id,
112
+ summary: item.json.subject,
113
+ start: item.json.start,
114
+ end: item.json.end
115
+ }));
116
+ return [
117
+ [],
118
+ [{
119
+ json: {
120
+ tool: (_f = this.getNode().type.description.aiTool) === null || _f === void 0 ? void 0 : _f.name,
121
+ parameters: { calendarId, returnAll },
122
+ toolOutput
123
+ }
124
+ }]
125
+ ];
126
+ }
127
+ catch (error) {
128
+ if (this.continueOnFail()) {
129
+ if (error instanceof Error) {
130
+ error.context = { itemIndex: 0 };
131
+ }
132
+ return [
133
+ [],
134
+ [{
135
+ json: {
136
+ error: error.message,
137
+ parameters: {
138
+ calendarId: this.getNodeParameter('calendarId', 0),
139
+ returnAll: this.getNodeParameter('returnAll', 0)
140
+ }
141
+ }
142
+ }]
143
+ ];
144
+ }
145
+ const errorContext = {
146
+ nodeId: this.getNode().id,
147
+ itemIndex: 0,
148
+ workflowId: this.getWorkflow().id
149
+ };
150
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, errorContext);
151
+ }
152
+ }
153
+ }
154
+ exports.CalendarToolWrapperX = CalendarToolWrapperX;
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@henry2323/n8n-nodes-calendar-tool-wrapper",
3
+ "version": "0.1.0",
4
+ "description": "Calendar Tool wrapper node for n8n",
5
+ "keywords": [
6
+ "n8n-community-node-package"
7
+ ],
8
+ "license": "MIT",
9
+ "homepage": "",
10
+ "author": {
11
+ "name": "henry2323"
12
+ },
13
+ "private": false,
14
+ "main": "index.js",
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "dev": "tsc --watch",
18
+ "format": "prettier nodes --write",
19
+ "lint": "eslint nodes package.json",
20
+ "lintfix": "eslint nodes package.json --fix",
21
+ "prepublishOnly": "npm run build",
22
+ "pretest": "npm run lint",
23
+ "test": "jest"
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "n8n": {
29
+ "n8nNodesApiVersion": 1,
30
+ "credentials": [],
31
+ "nodes": [
32
+ "dist/nodes/CalendarToolWrapperX/CalendarToolWrapperX.node.js"
33
+ ]
34
+ },
35
+ "dependencies": {
36
+ "n8n-nodes-base": "^1.14.1"
37
+ },
38
+ "devDependencies": {
39
+ "@types/express": "^4.17.6",
40
+ "@types/jest": "^26.0.13",
41
+ "@types/node": "^14.17.27",
42
+ "@typescript-eslint/parser": "^5.29.0",
43
+ "eslint-plugin-n8n-nodes-base": "^1.5.4",
44
+ "gulp": "^5.0.0",
45
+ "jest": "^29.7.0",
46
+ "n8n-core": "^1.75.0",
47
+ "n8n-workflow": "^1.70.0",
48
+ "prettier": "^2.7.1",
49
+ "ts-jest": "^29.2.5",
50
+ "typescript": "~4.6.4"
51
+ }
52
+ }