n8n-nodes-daytona-tool 0.1.2 → 0.1.3

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 CHANGED
@@ -9,6 +9,7 @@ Programmatic n8n community nodes for managing Daytona sandboxes and running Node
9
9
  - Daytona Dispose Sandbox
10
10
  - Daytona Start Sandbox
11
11
  - Daytona Stop Sandbox
12
+ - Daytona Upload File
12
13
 
13
14
  ## Credentials
14
15
 
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ const DisposeSandbox_node_1 = require("./nodes/Daytona/DisposeSandbox.node");
7
7
  const RunCode_node_1 = require("./nodes/Daytona/RunCode.node");
8
8
  const StartSandbox_node_1 = require("./nodes/Daytona/StartSandbox.node");
9
9
  const StopSandbox_node_1 = require("./nodes/Daytona/StopSandbox.node");
10
+ const UploadFile_node_1 = require("./nodes/Daytona/UploadFile.node");
10
11
  exports.credentials = [new DaytonaApi_credentials_1.DaytonaApi()];
11
12
  exports.nodes = [
12
13
  new CreateSandbox_node_1.CreateSandbox(),
@@ -14,4 +15,5 @@ exports.nodes = [
14
15
  new DisposeSandbox_node_1.DisposeSandbox(),
15
16
  new StartSandbox_node_1.StartSandbox(),
16
17
  new StopSandbox_node_1.StopSandbox(),
18
+ new UploadFile_node_1.UploadFile(),
17
19
  ];
@@ -16,4 +16,6 @@ export declare const runNodeCode: (sandbox: any, code: string, timeoutMs?: numbe
16
16
  export declare const disposeSandbox: (sandbox: any) => Promise<any>;
17
17
  export declare const startSandbox: (sandbox: any) => Promise<any>;
18
18
  export declare const stopSandbox: (sandbox: any) => Promise<any>;
19
+ export declare const createSandboxFile: (content: string, name: string, contentType?: string) => import("node:buffer").File;
20
+ export declare const uploadSandboxFile: (sandbox: any, remotePath: string, file: File) => Promise<any>;
19
21
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stopSandbox = exports.startSandbox = exports.disposeSandbox = exports.runNodeCode = exports.getSandboxByName = exports.getSandbox = exports.createSandbox = exports.createDaytonaClient = void 0;
3
+ exports.uploadSandboxFile = exports.createSandboxFile = exports.stopSandbox = exports.startSandbox = exports.disposeSandbox = exports.runNodeCode = exports.getSandboxByName = exports.getSandbox = exports.createSandbox = exports.createDaytonaClient = void 0;
4
4
  const sdk_1 = require("@daytonaio/sdk");
5
5
  const getCreateFn = (client) => { var _a, _b; return (_a = client === null || client === void 0 ? void 0 : client.create) !== null && _a !== void 0 ? _a : (_b = client === null || client === void 0 ? void 0 : client.sandbox) === null || _b === void 0 ? void 0 : _b.create; };
6
6
  const getFetchFn = (client) => { var _a, _b, _c, _d; return (_c = (_a = client === null || client === void 0 ? void 0 : client.get) !== null && _a !== void 0 ? _a : (_b = client === null || client === void 0 ? void 0 : client.sandbox) === null || _b === void 0 ? void 0 : _b.get) !== null && _c !== void 0 ? _c : (_d = client === null || client === void 0 ? void 0 : client.sandbox) === null || _d === void 0 ? void 0 : _d.connect; };
@@ -93,3 +93,24 @@ const stopSandbox = async (sandbox) => {
93
93
  return stopFn.call(sandbox);
94
94
  };
95
95
  exports.stopSandbox = stopSandbox;
96
+ const createSandboxFile = (content, name, contentType) => {
97
+ const FileCtor = globalThis
98
+ .File;
99
+ if (!FileCtor) {
100
+ throw new Error('File constructor is not available in this runtime.');
101
+ }
102
+ return new FileCtor([content], name, {
103
+ type: contentType || 'text/plain',
104
+ });
105
+ };
106
+ exports.createSandboxFile = createSandboxFile;
107
+ const uploadSandboxFile = async (sandbox, remotePath, file) => {
108
+ var _a, _b;
109
+ const fsApi = (_a = sandbox === null || sandbox === void 0 ? void 0 : sandbox.fs) !== null && _a !== void 0 ? _a : sandbox;
110
+ const uploadFn = (_b = fsApi === null || fsApi === void 0 ? void 0 : fsApi.uploadFile) !== null && _b !== void 0 ? _b : fsApi === null || fsApi === void 0 ? void 0 : fsApi.upload;
111
+ if (!uploadFn) {
112
+ throw new Error('Daytona SDK: upload file method not found.');
113
+ }
114
+ return uploadFn.call(fsApi, remotePath, file);
115
+ };
116
+ exports.uploadSandboxFile = uploadSandboxFile;
@@ -0,0 +1,5 @@
1
+ import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class UploadFile implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UploadFile = void 0;
4
+ const daytonaClient_1 = require("../../lib/daytonaClient");
5
+ class UploadFile {
6
+ constructor() {
7
+ this.description = {
8
+ displayName: 'Daytona Upload File',
9
+ name: 'daytonaUploadFile',
10
+ group: ['transform'],
11
+ version: 1,
12
+ description: 'Upload a file to a Daytona sandbox.',
13
+ defaults: {
14
+ name: 'Daytona Upload File',
15
+ },
16
+ inputs: ['main'],
17
+ outputs: ['main'],
18
+ usableAsTool: true,
19
+ credentials: [
20
+ {
21
+ name: 'daytonaApi',
22
+ required: true,
23
+ },
24
+ ],
25
+ properties: [
26
+ {
27
+ displayName: 'Identifier',
28
+ name: 'identifier',
29
+ type: 'string',
30
+ default: '',
31
+ required: true,
32
+ description: 'Sandbox ID or name.',
33
+ },
34
+ {
35
+ displayName: 'Identifier Type',
36
+ name: 'identifierType',
37
+ type: 'options',
38
+ default: 'id',
39
+ options: [
40
+ {
41
+ name: 'ID',
42
+ value: 'id',
43
+ },
44
+ {
45
+ name: 'Name',
46
+ value: 'name',
47
+ },
48
+ ],
49
+ },
50
+ {
51
+ displayName: 'Remote Path',
52
+ name: 'remotePath',
53
+ type: 'string',
54
+ default: 'workspace/file.txt',
55
+ required: true,
56
+ description: 'Path inside the sandbox (for example: workspace/file.txt).',
57
+ },
58
+ {
59
+ displayName: 'File Name',
60
+ name: 'fileName',
61
+ type: 'string',
62
+ default: 'file.txt',
63
+ required: true,
64
+ description: 'File name used when creating the File object.',
65
+ },
66
+ {
67
+ displayName: 'Content Type',
68
+ name: 'contentType',
69
+ type: 'string',
70
+ default: 'text/plain',
71
+ description: 'Optional MIME type.',
72
+ },
73
+ {
74
+ displayName: 'Content',
75
+ name: 'content',
76
+ type: 'string',
77
+ typeOptions: {
78
+ rows: 10,
79
+ },
80
+ default: '',
81
+ required: true,
82
+ description: 'File content to upload.',
83
+ },
84
+ ],
85
+ };
86
+ }
87
+ async execute() {
88
+ var _a, _b, _c, _d, _e;
89
+ const items = this.getInputData();
90
+ const credentials = await this.getCredentials('daytonaApi');
91
+ const client = (0, daytonaClient_1.createDaytonaClient)({
92
+ baseUrl: credentials.baseUrl,
93
+ token: credentials.token,
94
+ });
95
+ const returnData = [];
96
+ for (let i = 0; i < items.length; i++) {
97
+ const identifier = this.getNodeParameter('identifier', i);
98
+ const identifierType = this.getNodeParameter('identifierType', i);
99
+ const remotePath = this.getNodeParameter('remotePath', i);
100
+ const fileName = this.getNodeParameter('fileName', i);
101
+ const contentType = this.getNodeParameter('contentType', i);
102
+ const content = this.getNodeParameter('content', i);
103
+ const sandbox = identifierType === 'name'
104
+ ? await (0, daytonaClient_1.getSandboxByName)(client, identifier)
105
+ : await (0, daytonaClient_1.getSandbox)(client, identifier);
106
+ const file = (0, daytonaClient_1.createSandboxFile)(content, fileName, contentType);
107
+ const result = await (0, daytonaClient_1.uploadSandboxFile)(sandbox, remotePath, file);
108
+ returnData.push({
109
+ json: {
110
+ identifier,
111
+ identifierType,
112
+ sandboxId: (_b = (_a = sandbox === null || sandbox === void 0 ? void 0 : sandbox.id) !== null && _a !== void 0 ? _a : sandbox === null || sandbox === void 0 ? void 0 : sandbox.sandboxId) !== null && _b !== void 0 ? _b : (_c = sandbox === null || sandbox === void 0 ? void 0 : sandbox.metadata) === null || _c === void 0 ? void 0 : _c.id,
113
+ name: (_d = sandbox === null || sandbox === void 0 ? void 0 : sandbox.name) !== null && _d !== void 0 ? _d : (_e = sandbox === null || sandbox === void 0 ? void 0 : sandbox.metadata) === null || _e === void 0 ? void 0 : _e.name,
114
+ remotePath,
115
+ fileName,
116
+ uploaded: true,
117
+ raw: result !== null && result !== void 0 ? result : null,
118
+ },
119
+ });
120
+ }
121
+ return [returnData];
122
+ }
123
+ }
124
+ exports.UploadFile = UploadFile;
@@ -0,0 +1,20 @@
1
+ {
2
+ "node": "n8n-nodes-daytona-tool.UploadFile",
3
+ "nodeVersion": "1.0",
4
+ "codexVersion": "1.0",
5
+ "categories": [
6
+ "Development"
7
+ ],
8
+ "resources": {
9
+ "credentialDocumentation": [
10
+ {
11
+ "url": "https://www.daytona.io/docs/en/typescript-sdk/"
12
+ }
13
+ ],
14
+ "primaryDocumentation": [
15
+ {
16
+ "url": "https://www.daytona.io/docs/en/typescript-sdk/"
17
+ }
18
+ ]
19
+ }
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-daytona-tool",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "n8n community nodes for running code in Daytona sandboxes.",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",
@@ -46,7 +46,8 @@
46
46
  "dist/nodes/Daytona/RunCode.node.js",
47
47
  "dist/nodes/Daytona/DisposeSandbox.node.js",
48
48
  "dist/nodes/Daytona/StartSandbox.node.js",
49
- "dist/nodes/Daytona/StopSandbox.node.js"
49
+ "dist/nodes/Daytona/StopSandbox.node.js",
50
+ "dist/nodes/Daytona/UploadFile.node.js"
50
51
  ]
51
52
  }
52
53
  }