@activepieces/piece-sftp 0.2.4 → 0.3.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/package.json +27 -9
- package/src/index.d.ts +13 -1
- package/src/index.js +101 -23
- package/src/index.js.map +1 -1
- package/src/lib/actions/create-file.d.ts +1 -0
- package/src/lib/actions/create-file.js +38 -21
- package/src/lib/actions/create-file.js.map +1 -1
- package/src/lib/actions/create-folder.d.ts +10 -0
- package/src/lib/actions/create-folder.js +58 -0
- package/src/lib/actions/create-folder.js.map +1 -0
- package/src/lib/actions/delete-file.d.ts +9 -0
- package/src/lib/actions/delete-file.js +61 -0
- package/src/lib/actions/delete-file.js.map +1 -0
- package/src/lib/actions/delete-folder.d.ts +10 -0
- package/src/lib/actions/delete-folder.js +74 -0
- package/src/lib/actions/delete-folder.js.map +1 -0
- package/src/lib/actions/list-files.d.ts +9 -0
- package/src/lib/actions/list-files.js +80 -0
- package/src/lib/actions/list-files.js.map +1 -0
- package/src/lib/actions/read-file.d.ts +1 -0
- package/src/lib/actions/read-file.js +53 -20
- package/src/lib/actions/read-file.js.map +1 -1
- package/src/lib/actions/rename-file-or-folder.d.ts +11 -0
- package/src/lib/actions/rename-file-or-folder.js +73 -0
- package/src/lib/actions/rename-file-or-folder.js.map +1 -0
- package/src/lib/actions/upload-file.d.ts +10 -0
- package/src/lib/actions/upload-file.js +74 -0
- package/src/lib/actions/upload-file.js.map +1 -0
- package/src/lib/triggers/new-modified-file.d.ts +3 -0
- package/src/lib/triggers/new-modified-file.js +35 -45
- package/src/lib/triggers/new-modified-file.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,20 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@activepieces/piece-sftp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@
|
|
6
|
-
"
|
|
5
|
+
"@anthropic-ai/sdk": "0.27.3",
|
|
6
|
+
"@sinclair/typebox": "0.33.18",
|
|
7
|
+
"axios": "1.7.8",
|
|
8
|
+
"axios-retry": "4.4.1",
|
|
9
|
+
"basic-ftp": "5.0.5",
|
|
7
10
|
"dayjs": "1.11.9",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
11
|
+
"deepmerge": "4.3.1",
|
|
12
|
+
"mime-types": "2.1.35",
|
|
10
13
|
"nanoid": "3.3.6",
|
|
14
|
+
"openai": "4.67.1",
|
|
15
|
+
"replicate": "0.34.1",
|
|
11
16
|
"semver": "7.6.0",
|
|
12
17
|
"ssh2-sftp-client": "9.1.0",
|
|
13
|
-
"
|
|
14
|
-
"@activepieces/pieces-
|
|
15
|
-
"@activepieces/
|
|
18
|
+
"zod": "3.23.8",
|
|
19
|
+
"@activepieces/pieces-common": "0.2.34",
|
|
20
|
+
"@activepieces/pieces-framework": "0.7.41",
|
|
21
|
+
"@activepieces/shared": "0.10.131",
|
|
16
22
|
"tslib": "1.14.1"
|
|
17
23
|
},
|
|
24
|
+
"overrides": {
|
|
25
|
+
"@tryfabric/martian": {
|
|
26
|
+
"@notionhq/client": "$@notionhq/client"
|
|
27
|
+
},
|
|
28
|
+
"vite": {
|
|
29
|
+
"rollup": "npm:@rollup/wasm-node"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"resolutions": {
|
|
33
|
+
"rollup": "npm:@rollup/wasm-node"
|
|
34
|
+
},
|
|
18
35
|
"main": "./src/index.js",
|
|
19
|
-
"type": "commonjs"
|
|
36
|
+
"type": "commonjs",
|
|
37
|
+
"types": "./src/index.d.ts"
|
|
20
38
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
+
import Client from 'ssh2-sftp-client';
|
|
2
|
+
import { Client as FTPClient } from 'basic-ftp';
|
|
3
|
+
export declare function getClient<T extends Client | FTPClient>(auth: {
|
|
4
|
+
protocol: string;
|
|
5
|
+
host: string;
|
|
6
|
+
port: number;
|
|
7
|
+
username: string;
|
|
8
|
+
password: string;
|
|
9
|
+
}): Promise<T>;
|
|
10
|
+
export declare function endClient(client: Client | FTPClient): Promise<void>;
|
|
1
11
|
export declare const sftpAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
12
|
+
protocol: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
2
13
|
host: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
14
|
port: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
4
15
|
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
5
16
|
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
6
17
|
}>;
|
|
7
|
-
export declare const
|
|
18
|
+
export declare const ftpSftp: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
19
|
+
protocol: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
8
20
|
host: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
9
21
|
port: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
10
22
|
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
package/src/index.js
CHANGED
|
@@ -1,49 +1,110 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ftpSftp = exports.sftpAuth = void 0;
|
|
4
|
+
exports.getClient = getClient;
|
|
5
|
+
exports.endClient = endClient;
|
|
4
6
|
const tslib_1 = require("tslib");
|
|
5
7
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
8
|
const shared_1 = require("@activepieces/shared");
|
|
7
9
|
const ssh2_sftp_client_1 = tslib_1.__importDefault(require("ssh2-sftp-client"));
|
|
10
|
+
const basic_ftp_1 = require("basic-ftp");
|
|
8
11
|
const create_file_1 = require("./lib/actions/create-file");
|
|
12
|
+
const upload_file_1 = require("./lib/actions/upload-file");
|
|
9
13
|
const read_file_1 = require("./lib/actions/read-file");
|
|
10
14
|
const new_modified_file_1 = require("./lib/triggers/new-modified-file");
|
|
15
|
+
const delete_folder_1 = require("./lib/actions/delete-folder");
|
|
16
|
+
const delete_file_1 = require("./lib/actions/delete-file");
|
|
17
|
+
const list_files_1 = require("./lib/actions/list-files");
|
|
18
|
+
const create_folder_1 = require("./lib/actions/create-folder");
|
|
19
|
+
const rename_file_or_folder_1 = require("./lib/actions/rename-file-or-folder");
|
|
20
|
+
function getClient(auth) {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const { protocol, host, port, username, password } = auth;
|
|
23
|
+
if (protocol === 'sftp') {
|
|
24
|
+
const sftp = new ssh2_sftp_client_1.default();
|
|
25
|
+
yield sftp.connect({
|
|
26
|
+
host,
|
|
27
|
+
port,
|
|
28
|
+
username,
|
|
29
|
+
password,
|
|
30
|
+
timeout: 10000,
|
|
31
|
+
});
|
|
32
|
+
return sftp;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const ftpClient = new basic_ftp_1.Client();
|
|
36
|
+
yield ftpClient.access({
|
|
37
|
+
host,
|
|
38
|
+
port,
|
|
39
|
+
user: username,
|
|
40
|
+
password,
|
|
41
|
+
secure: protocol === 'ftps',
|
|
42
|
+
});
|
|
43
|
+
return ftpClient;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function endClient(client) {
|
|
48
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
if (client instanceof ssh2_sftp_client_1.default) {
|
|
50
|
+
yield client.end();
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
client.close();
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
11
57
|
exports.sftpAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
12
|
-
description: 'Enter the authentication details',
|
|
13
58
|
props: {
|
|
59
|
+
protocol: pieces_framework_1.Property.StaticDropdown({
|
|
60
|
+
displayName: 'Protocol',
|
|
61
|
+
description: 'The protocol to use',
|
|
62
|
+
required: true,
|
|
63
|
+
options: {
|
|
64
|
+
options: [
|
|
65
|
+
{ value: 'sftp', label: 'SFTP' },
|
|
66
|
+
{ value: 'ftp', label: 'FTP' },
|
|
67
|
+
{ value: 'ftps', label: 'FTPS' }
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
}),
|
|
14
71
|
host: pieces_framework_1.Property.ShortText({
|
|
15
72
|
displayName: 'Host',
|
|
16
|
-
description: 'The host of the
|
|
73
|
+
description: 'The host of the server',
|
|
17
74
|
required: true,
|
|
18
75
|
}),
|
|
19
76
|
port: pieces_framework_1.Property.Number({
|
|
20
77
|
displayName: 'Port',
|
|
21
|
-
description: 'The port of the
|
|
78
|
+
description: 'The port of the server',
|
|
22
79
|
required: true,
|
|
23
80
|
defaultValue: 22,
|
|
24
81
|
}),
|
|
25
82
|
username: pieces_framework_1.Property.ShortText({
|
|
26
83
|
displayName: 'Username',
|
|
27
|
-
description: 'The username
|
|
84
|
+
description: 'The username to authenticate with',
|
|
28
85
|
required: true,
|
|
29
86
|
}),
|
|
30
87
|
password: pieces_framework_1.PieceAuth.SecretText({
|
|
31
88
|
displayName: 'Password',
|
|
32
|
-
description: 'The password
|
|
89
|
+
description: 'The password to authenticate with',
|
|
33
90
|
required: true,
|
|
34
91
|
}),
|
|
35
92
|
},
|
|
36
|
-
validate: (
|
|
37
|
-
|
|
38
|
-
const sftp = new ssh2_sftp_client_1.default();
|
|
93
|
+
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
94
|
+
let client = null;
|
|
39
95
|
try {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
96
|
+
switch (auth.protocol) {
|
|
97
|
+
case 'sftp': {
|
|
98
|
+
client = yield getClient(auth);
|
|
99
|
+
yield client.end();
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
default: {
|
|
103
|
+
client = yield getClient(auth);
|
|
104
|
+
client.close();
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
47
108
|
return {
|
|
48
109
|
valid: true,
|
|
49
110
|
};
|
|
@@ -55,20 +116,37 @@ exports.sftpAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
|
55
116
|
};
|
|
56
117
|
}
|
|
57
118
|
finally {
|
|
58
|
-
|
|
119
|
+
if (client) {
|
|
120
|
+
yield endClient(client);
|
|
121
|
+
}
|
|
59
122
|
}
|
|
60
123
|
}),
|
|
61
124
|
required: true,
|
|
62
125
|
});
|
|
63
|
-
exports.
|
|
64
|
-
displayName: 'SFTP',
|
|
65
|
-
description: '
|
|
66
|
-
minimumSupportedRelease: '0.
|
|
126
|
+
exports.ftpSftp = (0, pieces_framework_1.createPiece)({
|
|
127
|
+
displayName: 'FTP/SFTP',
|
|
128
|
+
description: 'Connect to FTP, FTPS or SFTP servers',
|
|
129
|
+
minimumSupportedRelease: '0.30.0',
|
|
67
130
|
logoUrl: 'https://cdn.activepieces.com/pieces/sftp.svg',
|
|
68
131
|
categories: [shared_1.PieceCategory.CORE, shared_1.PieceCategory.DEVELOPER_TOOLS],
|
|
69
|
-
authors: [
|
|
132
|
+
authors: [
|
|
133
|
+
'Abdallah-Alwarawreh',
|
|
134
|
+
'kishanprmr',
|
|
135
|
+
'AbdulTheActivePiecer',
|
|
136
|
+
'khaledmashaly',
|
|
137
|
+
'abuaboud',
|
|
138
|
+
],
|
|
70
139
|
auth: exports.sftpAuth,
|
|
71
|
-
actions: [
|
|
140
|
+
actions: [
|
|
141
|
+
create_file_1.createFile,
|
|
142
|
+
upload_file_1.uploadFileAction,
|
|
143
|
+
read_file_1.readFileContent,
|
|
144
|
+
delete_file_1.deleteFileAction,
|
|
145
|
+
create_folder_1.createFolderAction,
|
|
146
|
+
delete_folder_1.deleteFolderAction,
|
|
147
|
+
list_files_1.listFolderContentsAction,
|
|
148
|
+
rename_file_or_folder_1.renameFileOrFolderAction,
|
|
149
|
+
],
|
|
72
150
|
triggers: [new_modified_file_1.newOrModifiedFile],
|
|
73
151
|
});
|
|
74
152
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/sftp/src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/sftp/src/index.ts"],"names":[],"mappings":";;;AAkBA,8BAwBC;AAED,8BAMC;;AAlDD,qEAIwC;AACxC,iDAAqD;AACrD,gFAAsC;AACtC,yCAAgD;AAChD,2DAAuD;AACvD,2DAA6D;AAC7D,uDAA0D;AAC1D,wEAAqE;AACrE,+DAAiE;AACjE,2DAA6D;AAC7D,yDAAoE;AACpE,+DAAiE;AACjE,+EAA+E;AAE/E,SAAsB,SAAS,CAA+B,IAA0F;;QACtJ,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAE1D,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;YACxB,MAAM,IAAI,GAAG,IAAI,0BAAM,EAAE,CAAC;YAC1B,MAAM,IAAI,CAAC,OAAO,CAAC;gBACjB,IAAI;gBACJ,IAAI;gBACJ,QAAQ;gBACR,QAAQ;gBACR,OAAO,EAAE,KAAK;aACf,CAAC,CAAC;YACH,OAAO,IAAS,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,MAAM,SAAS,GAAG,IAAI,kBAAS,EAAE,CAAC;YAClC,MAAM,SAAS,CAAC,MAAM,CAAC;gBACrB,IAAI;gBACJ,IAAI;gBACJ,IAAI,EAAE,QAAQ;gBACd,QAAQ;gBACR,MAAM,EAAE,QAAQ,KAAK,MAAM;aAC5B,CAAC,CAAC;YACH,OAAO,SAAc,CAA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kCAAkB;QAClB,qCAAwB;QACxB,gDAAwB;KACzB;IACD,QAAQ,EAAE,CAAC,qCAAiB,CAAC;CAC9B,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const createFile: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
protocol: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
2
3
|
host: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
4
|
port: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
4
5
|
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
@@ -3,8 +3,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createFile = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
-
const ssh2_sftp_client_1 = tslib_1.__importDefault(require("ssh2-sftp-client"));
|
|
7
6
|
const __1 = require("../..");
|
|
7
|
+
const stream_1 = require("stream");
|
|
8
|
+
function createFileWithSFTP(client, fileName, fileContent) {
|
|
9
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
|
+
const remotePathExists = yield client.exists(fileName);
|
|
11
|
+
if (!remotePathExists) {
|
|
12
|
+
// Extract the directory path from the fileName
|
|
13
|
+
const remoteDirectory = fileName.substring(0, fileName.lastIndexOf('/'));
|
|
14
|
+
// Create the directory if it doesn't exist
|
|
15
|
+
yield client.mkdir(remoteDirectory, true);
|
|
16
|
+
}
|
|
17
|
+
yield client.put(Buffer.from(fileContent), fileName);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function createFileWithFTP(client, fileName, fileContent) {
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
// Extract the directory path from the fileName
|
|
23
|
+
const remoteDirectory = fileName.substring(0, fileName.lastIndexOf('/'));
|
|
24
|
+
// Create the directory if it doesn't exist
|
|
25
|
+
yield client.ensureDir(remoteDirectory);
|
|
26
|
+
// Upload the file content
|
|
27
|
+
const buffer = Buffer.from(fileContent);
|
|
28
|
+
yield client.uploadFrom(stream_1.Readable.from(buffer), fileName);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
8
31
|
exports.createFile = (0, pieces_framework_1.createAction)({
|
|
9
32
|
auth: __1.sftpAuth,
|
|
10
33
|
name: 'create_file',
|
|
@@ -22,40 +45,34 @@ exports.createFile = (0, pieces_framework_1.createAction)({
|
|
|
22
45
|
},
|
|
23
46
|
run(context) {
|
|
24
47
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const host = context.auth.host;
|
|
26
|
-
const port = context.auth.port;
|
|
27
|
-
const username = context.auth.username;
|
|
28
|
-
const password = context.auth.password;
|
|
29
48
|
const fileName = context.propsValue['fileName'];
|
|
30
49
|
const fileContent = context.propsValue['fileContent'];
|
|
31
|
-
const
|
|
50
|
+
const client = yield (0, __1.getClient)(context.auth);
|
|
32
51
|
try {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const remoteDirectory = fileName.substring(0, fileName.lastIndexOf('/'));
|
|
43
|
-
// Create the directory if it doesn't exist
|
|
44
|
-
yield sftp.mkdir(remoteDirectory, true); // The second argument 'true' makes the function create all intermediate directories
|
|
45
|
-
// You can also check if the directory was successfully created and handle any potential errors here
|
|
52
|
+
switch (context.auth.protocol) {
|
|
53
|
+
case 'ftps':
|
|
54
|
+
case 'ftp':
|
|
55
|
+
yield createFileWithFTP(client, fileName, fileContent);
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
case 'sftp':
|
|
59
|
+
yield createFileWithSFTP(client, fileName, fileContent);
|
|
60
|
+
break;
|
|
46
61
|
}
|
|
47
|
-
yield sftp.put(Buffer.from(fileContent), fileName);
|
|
48
|
-
yield sftp.end();
|
|
49
62
|
return {
|
|
50
63
|
status: 'success',
|
|
51
64
|
};
|
|
52
65
|
}
|
|
53
66
|
catch (err) {
|
|
67
|
+
console.error(err);
|
|
54
68
|
return {
|
|
55
69
|
status: 'error',
|
|
56
70
|
error: err,
|
|
57
71
|
};
|
|
58
72
|
}
|
|
73
|
+
finally {
|
|
74
|
+
yield (0, __1.endClient)(client);
|
|
75
|
+
}
|
|
59
76
|
});
|
|
60
77
|
},
|
|
61
78
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sftp/src/lib/actions/create-file.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;
|
|
1
|
+
{"version":3,"file":"create-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sftp/src/lib/actions/create-file.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AAGxE,6BAAuD;AACvD,mCAAkC;AAElC,SAAe,kBAAkB,CAAC,MAAc,EAAE,QAAgB,EAAE,WAAmB;;QACnF,MAAM,gBAAgB,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACvD,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACpB,+CAA+C;YAC/C,MAAM,eAAe,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;YACzE,2CAA2C;YAC3C,MAAM,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QAC9C,CAAC;QACD,MAAM,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC;CAAA;AAED,SAAe,iBAAiB,CAAC,MAAiB,EAAE,QAAgB,EAAE,WAAmB;;QACrF,+CAA+C;QAC/C,MAAM,eAAe,GAAG,QAAQ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MAAgB,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;wBAClE,MAAM;gBACd,CAAC;gBAED,OAAO;oBACH,MAAM,EAAE,SAAS;iBACpB,CAAC;YACN,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACX,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACnB,OAAO;oBACH,MAAM,EAAE,OAAO;oBACf,KAAK,EAAE,GAAG;iBACb,CAAC;YACN,CAAC;oBAAS,CAAC;gBACP,MAAM,IAAA,aAAS,EAAC,MAAM,CAAC,CAAC;YAC5B,CAAC;QACL,CAAC;KAAA;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const createFolderAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
protocol: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
3
|
+
host: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
port: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
5
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
6
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
7
|
+
}>, {
|
|
8
|
+
folderPath: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
9
|
+
recursive: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFolderAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const index_1 = require("../../index");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
exports.createFolderAction = (0, pieces_framework_1.createAction)({
|
|
8
|
+
auth: index_1.sftpAuth,
|
|
9
|
+
name: 'createFolder',
|
|
10
|
+
displayName: 'Create Folder',
|
|
11
|
+
description: 'Creates a folder at given path.',
|
|
12
|
+
props: {
|
|
13
|
+
folderPath: pieces_framework_1.Property.ShortText({
|
|
14
|
+
displayName: 'Folder Path',
|
|
15
|
+
required: true,
|
|
16
|
+
description: 'The new folder path e.g. `./myfolder`. For FTP/FTPS, it will create nested folders if necessary.',
|
|
17
|
+
}),
|
|
18
|
+
recursive: pieces_framework_1.Property.Checkbox({
|
|
19
|
+
displayName: 'Recursive',
|
|
20
|
+
defaultValue: false,
|
|
21
|
+
required: false,
|
|
22
|
+
description: 'For SFTP only: Create parent directories if they do not exist',
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
run(context) {
|
|
26
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
var _a;
|
|
28
|
+
const client = yield (0, index_1.getClient)(context.auth);
|
|
29
|
+
const directoryPath = context.propsValue.folderPath;
|
|
30
|
+
const recursive = (_a = context.propsValue.recursive) !== null && _a !== void 0 ? _a : false;
|
|
31
|
+
try {
|
|
32
|
+
switch (context.auth.protocol) {
|
|
33
|
+
case 'ftps':
|
|
34
|
+
case 'ftp':
|
|
35
|
+
yield client.ensureDir(directoryPath);
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
case 'sftp':
|
|
39
|
+
yield client.mkdir(directoryPath, recursive);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
status: 'success',
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
return {
|
|
48
|
+
status: 'error',
|
|
49
|
+
error: err,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
yield (0, index_1.endClient)(client);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=create-folder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-folder.js","sour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ACL,MAAM,EAAE,OAAO;oBACf,KAAK,EAAE,GAAG;iBACX,CAAC;YACJ,CAAC;oBAAS,CAAC;gBACT,MAAM,IAAA,iBAAS,EAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const deleteFileAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
protocol: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
3
|
+
host: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
port: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
5
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
6
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
7
|
+
}>, {
|
|
8
|
+
filePath: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteFileAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const __1 = require("../..");
|
|
7
|
+
function deleteFileFromFTP(client, filePath) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
yield client.remove(filePath);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function deleteFileFromSFTP(client, filePath) {
|
|
13
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
14
|
+
yield client.delete(filePath);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
exports.deleteFileAction = (0, pieces_framework_1.createAction)({
|
|
18
|
+
auth: __1.sftpAuth,
|
|
19
|
+
name: 'deleteFile',
|
|
20
|
+
displayName: 'Delete file',
|
|
21
|
+
description: 'Deletes a file at given path.',
|
|
22
|
+
props: {
|
|
23
|
+
filePath: pieces_framework_1.Property.ShortText({
|
|
24
|
+
displayName: 'File Path',
|
|
25
|
+
required: true,
|
|
26
|
+
description: 'The path of the file to delete e.g. `./myfolder/test.mp3`',
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
run(context) {
|
|
30
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const client = yield (0, __1.getClient)(context.auth);
|
|
32
|
+
const filePath = context.propsValue.filePath;
|
|
33
|
+
try {
|
|
34
|
+
switch (context.auth.protocol) {
|
|
35
|
+
case 'ftps':
|
|
36
|
+
case 'ftp':
|
|
37
|
+
yield deleteFileFromFTP(client, filePath);
|
|
38
|
+
break;
|
|
39
|
+
default:
|
|
40
|
+
case 'sftp':
|
|
41
|
+
yield deleteFileFromSFTP(client, filePath);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
status: 'success',
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
console.error(err);
|
|
50
|
+
return {
|
|
51
|
+
status: 'error',
|
|
52
|
+
error: err,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
yield (0, __1.endClient)(client);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=delete-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sftp/src/lib/actions/delete-file.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,6BAAuD;AAIvD,SAAe,iBAAiB,CAAC,MAAiB,EAAE,QAAgB;;QAClE,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;CAAA;AAED,SAAe,kBAA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1,10 @@
|
|
|
1
|
+
export declare const deleteFolderAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
protocol: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
3
|
+
host: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
port: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
5
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
6
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
7
|
+
}>, {
|
|
8
|
+
folderPath: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
9
|
+
recursive: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteFolderAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const __1 = require("../..");
|
|
7
|
+
function deleteFolderFTP(client, directoryPath, recursive) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
if (recursive) {
|
|
10
|
+
yield client.removeDir(directoryPath);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
yield client.removeEmptyDir(directoryPath);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function deleteFolderSFTP(client, directoryPath, recursive) {
|
|
18
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
yield client.rmdir(directoryPath, recursive);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
exports.deleteFolderAction = (0, pieces_framework_1.createAction)({
|
|
23
|
+
auth: __1.sftpAuth,
|
|
24
|
+
name: 'deleteFolder',
|
|
25
|
+
displayName: 'Delete Folder',
|
|
26
|
+
description: 'Deletes an existing folder at given path.',
|
|
27
|
+
props: {
|
|
28
|
+
folderPath: pieces_framework_1.Property.ShortText({
|
|
29
|
+
displayName: 'Folder Path',
|
|
30
|
+
required: true,
|
|
31
|
+
description: 'The path of the folder to delete e.g. `./myfolder`',
|
|
32
|
+
}),
|
|
33
|
+
recursive: pieces_framework_1.Property.Checkbox({
|
|
34
|
+
displayName: 'Recursive',
|
|
35
|
+
defaultValue: false,
|
|
36
|
+
required: false,
|
|
37
|
+
description: 'Enable this option to delete the folder and all its contents, including subfolders and files.',
|
|
38
|
+
}),
|
|
39
|
+
},
|
|
40
|
+
run(context) {
|
|
41
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
var _a;
|
|
43
|
+
const client = yield (0, __1.getClient)(context.auth);
|
|
44
|
+
const directoryPath = context.propsValue.folderPath;
|
|
45
|
+
const recursive = (_a = context.propsValue.recursive) !== null && _a !== void 0 ? _a : false;
|
|
46
|
+
try {
|
|
47
|
+
switch (context.auth.protocol) {
|
|
48
|
+
case 'ftps':
|
|
49
|
+
case 'ftp':
|
|
50
|
+
yield deleteFolderFTP(client, directoryPath, recursive);
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
case 'sftp':
|
|
54
|
+
yield deleteFolderSFTP(client, directoryPath, recursive);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
status: 'success',
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
console.error(err);
|
|
63
|
+
return {
|
|
64
|
+
status: 'error',
|
|
65
|
+
error: err,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
yield (0, __1.endClient)(client);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=delete-folder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete-folder.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sftp/src/lib/actions/delete-folder.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AAGxE,6BAAuD;AAEvD,SAAe,eAAe,CAAC,MAAiB,EAAE,aAAqB,EAAE,SAAkB;;QACzF,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QACxC,CAAC;aAAM,CAAC;YACN,MAAM,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;CAAA;AAED,SAAe,gBAAgB,CAAC,MAAc,EAAE,aAAqB,EAAE,SAAkB;;QACvF,MAAM,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAC/C,CAAC;CAAA;AAEY,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC7C,IAAI,EAAE,YAAQ;IACd,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,2CAA2C;IACxD,KAAK,EAAE;QACL,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,aAAa;YAC1B,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,oDAAoD;SAClE,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC3B,WAAW,EAAE,WAAW;YACxB,YAAY,EAAE,KAAK;YACnB,QAAQ,EAAE,KAAK;YACf,WAAW,EACT,+FAA+F;SAClG,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;;YACf,MAAM,MAAM,GAAG,MAAM,IAAA,aAAS,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC7C,MAAM,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC;YACpD,MAAM,SAAS,GAAG,MAAA,OAAO,CAAC,UAAU,CAAC,SAAS,mCAAI,KAAK,CAAC;YAExD,IAAI,CAAC;gBACH,QAAQ,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;oBAC9B,KAAK,MAAM,CAAC;oBACZ,KAAK,KAAK;wBACR,MAAM,eAAe,CAAC,MAAmB,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;wBACrE,MAAM;oBACR,QAAQ;oBACR,KAAK,MAAM;wBACT,MAAM,gBAAgB,CAAC,MAAgB,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;wBACnE,MAAM;gBACV,CAAC;gBAED,OAAO;oBACL,MAAM,EAAE,SAAS;iBAClB,CAAC;YACJ,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACnB,OAAO;oBACL,MAAM,EAAE,OAAO;oBACf,KAAK,EAAE,GAAG;iBACX,CAAC;YACJ,CAAC;oBAAS,CAAC;gBACT,MAAM,IAAA,aAAS,EAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const listFolderContentsAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
protocol: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
3
|
+
host: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
port: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
5
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
6
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
7
|
+
}>, {
|
|
8
|
+
directoryPath: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listFolderContentsAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const index_1 = require("../../index");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const __1 = require("../..");
|
|
8
|
+
function listSFTP(client, directoryPath) {
|
|
9
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
|
+
const contents = yield client.list(directoryPath);
|
|
11
|
+
yield client.end();
|
|
12
|
+
return contents;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function listFTP(client, directoryPath) {
|
|
16
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const contents = yield client.list(directoryPath);
|
|
18
|
+
return contents.map(item => ({
|
|
19
|
+
type: item.type === 1 ? 'd' : '-',
|
|
20
|
+
name: item.name,
|
|
21
|
+
size: item.size,
|
|
22
|
+
modifyTime: item.modifiedAt,
|
|
23
|
+
accessTime: item.modifiedAt, // FTP doesn't provide access time
|
|
24
|
+
rights: {
|
|
25
|
+
user: item.permissions || '',
|
|
26
|
+
group: '',
|
|
27
|
+
other: ''
|
|
28
|
+
},
|
|
29
|
+
owner: '',
|
|
30
|
+
group: ''
|
|
31
|
+
}));
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.listFolderContentsAction = (0, pieces_framework_1.createAction)({
|
|
35
|
+
auth: index_1.sftpAuth,
|
|
36
|
+
name: 'listFolderContents',
|
|
37
|
+
displayName: 'List Folder Contents',
|
|
38
|
+
description: 'Lists the contents of a given folder.',
|
|
39
|
+
props: {
|
|
40
|
+
directoryPath: pieces_framework_1.Property.ShortText({
|
|
41
|
+
displayName: 'Directory Path',
|
|
42
|
+
required: true,
|
|
43
|
+
description: 'The path of the folder to list e.g. `./myfolder`',
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
run(context) {
|
|
47
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const client = yield (0, __1.getClient)(context.auth);
|
|
49
|
+
const directoryPath = context.propsValue.directoryPath;
|
|
50
|
+
try {
|
|
51
|
+
let contents;
|
|
52
|
+
switch (context.auth.protocol) {
|
|
53
|
+
case 'ftps':
|
|
54
|
+
case 'ftp':
|
|
55
|
+
contents = yield listFTP(client, directoryPath);
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
case 'sftp':
|
|
59
|
+
contents = yield listSFTP(client, directoryPath);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
status: 'success',
|
|
64
|
+
contents: contents,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
return {
|
|
69
|
+
status: 'error',
|
|
70
|
+
contents: null,
|
|
71
|
+
error: err,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
yield (0, index_1.endClient)(client);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=list-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-files.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sftp/src/lib/actions/list-files.ts"],"names":[],"mappings":";;;;AAAA,uCAAkD;AAClD,qEAAwE;AAGxE,6BAAkC;AAElC,SAAe,QAAQ,CAAC,MAAc,EAAE,aAAqB;;QAC3D,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAClD,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC;QACnB,OAAO,QAAQ,CAAC;IAClB,CAAC;CAAA;AAED,SAAe,OAAO,CAAC,MAAiB,EAAE,aAAqB;;QAC7D,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAClD,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC3B,IAAI,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC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ACV,CAAC;gBAED,OAAO;oBACL,MAAM,EAAE,SAAS;oBACjB,QAAQ,EAAE,QAAQ;iBACnB,CAAC;YACJ,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO;oBACL,MAAM,EAAE,OAAO;oBACf,QAAQ,EAAE,IAAI;oBACd,KAAK,EAAE,GAAG;iBACX,CAAC;YACJ,CAAC;oBAAS,CAAC;gBACT,MAAM,IAAA,iBAAS,EAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const readFileContent: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
protocol: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
2
3
|
host: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
4
|
port: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
4
5
|
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
@@ -4,12 +4,33 @@ exports.readFileContent = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const index_1 = require("../../index");
|
|
6
6
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
-
const
|
|
7
|
+
const __1 = require("../..");
|
|
8
|
+
const stream_1 = require("stream");
|
|
9
|
+
function readFTP(client, filePath) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
const chunks = [];
|
|
12
|
+
const writeStream = new stream_1.Writable({
|
|
13
|
+
write(chunk, _encoding, callback) {
|
|
14
|
+
chunks.push(chunk);
|
|
15
|
+
callback();
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
yield client.downloadTo(writeStream, filePath);
|
|
19
|
+
return Buffer.concat(chunks);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function readSFTP(client, filePath) {
|
|
23
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const fileContent = yield client.get(filePath);
|
|
25
|
+
yield client.end();
|
|
26
|
+
return fileContent;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
8
29
|
exports.readFileContent = (0, pieces_framework_1.createAction)({
|
|
9
30
|
auth: index_1.sftpAuth,
|
|
10
31
|
name: 'read_file_content',
|
|
11
32
|
displayName: 'Read File Content',
|
|
12
|
-
description: 'Read the content of a file',
|
|
33
|
+
description: 'Read the content of a file.',
|
|
13
34
|
props: {
|
|
14
35
|
filePath: pieces_framework_1.Property.ShortText({
|
|
15
36
|
displayName: 'File Path',
|
|
@@ -17,27 +38,39 @@ exports.readFileContent = (0, pieces_framework_1.createAction)({
|
|
|
17
38
|
}),
|
|
18
39
|
},
|
|
19
40
|
run(context) {
|
|
20
|
-
var _a;
|
|
21
41
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
|
|
42
|
+
var _a;
|
|
43
|
+
const client = yield (0, __1.getClient)(context.auth);
|
|
23
44
|
const filePath = context.propsValue['filePath'];
|
|
24
|
-
const sftp = new ssh2_sftp_client_1.default();
|
|
25
|
-
yield sftp.connect({
|
|
26
|
-
host,
|
|
27
|
-
port,
|
|
28
|
-
username,
|
|
29
|
-
password,
|
|
30
|
-
readyTimeout: 15000,
|
|
31
|
-
});
|
|
32
|
-
const fileContent = yield sftp.get(filePath);
|
|
33
45
|
const fileName = (_a = filePath.split('/').pop()) !== null && _a !== void 0 ? _a : filePath;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
try {
|
|
47
|
+
let fileContent;
|
|
48
|
+
switch (context.auth.protocol) {
|
|
49
|
+
case 'ftps':
|
|
50
|
+
case 'ftp':
|
|
51
|
+
fileContent = yield readFTP(client, filePath);
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
case 'sftp':
|
|
55
|
+
fileContent = yield readSFTP(client, filePath);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
file: yield context.files.write({
|
|
60
|
+
fileName: fileName,
|
|
61
|
+
data: fileContent,
|
|
62
|
+
}),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
return {
|
|
67
|
+
success: false,
|
|
68
|
+
error: err,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
yield (0, index_1.endClient)(client);
|
|
73
|
+
}
|
|
41
74
|
});
|
|
42
75
|
},
|
|
43
76
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sftp/src/lib/actions/read-file.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"read-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sftp/src/lib/actions/read-file.ts"],"names":[],"mappings":";;;;AAAA,uCAAkD;AAClD,qEAAwE;AAGxE,6BAAkC;AAClC,mCAAkC;AAElC,SAAe,OAAO,CAAC,MAAiB,EAAE,QAAgB;;QACxD,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,MAAM,WAAW,GAAG,IAAI,iBAAQ,CAAC;YAC/B,KAAK,CAAC,KAAa,EAAE,SAAiB,EAAE,QAAoB;gBAC1D,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACnB,QAAQ,EAAE,CAAC;YACb,CAAC;SACF,CAAC,CAAC;QACH,MAAM,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QAC/C,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;CAAA;AAED,SAAe,QAAQ,CAAC,MAAc,EAAE,QAAgB;;QACtD,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,QAAQ,CAA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E,KAAK;oBACd,KAAK,EAAE,GAAG;iBACX,CAAC;YACJ,CAAC;oBAAS,CAAC;gBACT,MAAM,IAAA,iBAAS,EAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const renameFileOrFolderAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
protocol: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
3
|
+
host: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
port: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
5
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
6
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
7
|
+
}>, {
|
|
8
|
+
information: import("dist/packages/pieces/community/framework/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
9
|
+
oldPath: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
10
|
+
newPath: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renameFileOrFolderAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const index_1 = require("../../index");
|
|
6
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
7
|
+
const __1 = require("../..");
|
|
8
|
+
const shared_1 = require("@activepieces/shared");
|
|
9
|
+
function renameFTP(client, oldPath, newPath) {
|
|
10
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
+
yield client.rename(oldPath, newPath);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
function renameSFTP(client, oldPath, newPath) {
|
|
15
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
yield client.rename(oldPath, newPath);
|
|
17
|
+
yield client.end();
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
exports.renameFileOrFolderAction = (0, pieces_framework_1.createAction)({
|
|
21
|
+
auth: index_1.sftpAuth,
|
|
22
|
+
name: 'renameFileOrFolder',
|
|
23
|
+
displayName: 'Rename File or Folder',
|
|
24
|
+
description: 'Renames a file or folder at given path.',
|
|
25
|
+
props: {
|
|
26
|
+
information: pieces_framework_1.Property.MarkDown({
|
|
27
|
+
value: 'Depending on the server you can also use this to move a file to another directory, as long as the directory exists.',
|
|
28
|
+
variant: shared_1.MarkdownVariant.INFO,
|
|
29
|
+
}),
|
|
30
|
+
oldPath: pieces_framework_1.Property.ShortText({
|
|
31
|
+
displayName: 'Old Path',
|
|
32
|
+
required: true,
|
|
33
|
+
description: 'The path of the file or folder to rename e.g. `./myfolder/test.mp3`',
|
|
34
|
+
}),
|
|
35
|
+
newPath: pieces_framework_1.Property.ShortText({
|
|
36
|
+
displayName: 'New Path',
|
|
37
|
+
required: true,
|
|
38
|
+
description: 'The new path of the file or folder e.g. `./myfolder/new-name.mp3`',
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
run(context) {
|
|
42
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const client = yield (0, __1.getClient)(context.auth);
|
|
44
|
+
const oldPath = context.propsValue.oldPath;
|
|
45
|
+
const newPath = context.propsValue.newPath;
|
|
46
|
+
try {
|
|
47
|
+
switch (context.auth.protocol) {
|
|
48
|
+
case 'ftps':
|
|
49
|
+
case 'ftp':
|
|
50
|
+
yield renameFTP(client, oldPath, newPath);
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
case 'sftp':
|
|
54
|
+
yield renameSFTP(client, oldPath, newPath);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
status: 'success',
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
return {
|
|
63
|
+
status: 'error',
|
|
64
|
+
error: err,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
yield (0, index_1.endClient)(client);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=rename-file-or-folder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-file-or-folder.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sftp/src/lib/actions/rename-file-or-folder.ts"],"names":[],"mappings":";;;;AAAA,uCAAkD;AAClD,qEAAwE;AAGxE,6BAAkC;AAClC,iDAAuD;AAEvD,SAAe,SAAS,CAAC,MAAiB,EAAE,OAAe,EAAE,OAAe;;QAC1E,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;CAAA;AAED,SAAe,UAAU,CAAC,MAAc,EAAE,OAAe,EAAE,OAAe;;QACxE,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACtC,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC;IACrB,CAAC;CAAA;AAEY,QAAA,wBAAwB,GAAG,IAAA,+BAAY,EAAC;IACnD,IAAI,EAAE,gBAAQ;IACd,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,uBAAuB;IACpC,WAAW,EAAE,yCAAyC;IACtD,KAAK,EAAE;QACL,WAAW,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC7B,KAAK,EAAE,qHAAqH;YAC5H,OAAO,EAAE,wBAAe,CAAC,IAAI;SAC9B,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,UAAU;YACvB,QAAQ,EAAE,IAAI;YACd,WAAW,EACT,qEAAqE;SACxE,CAAC;QACF,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,UAAU;YACvB,QAAQ,EAAE,IAAI;YACd,WAAW,EACT,mEAAmE;SACtE,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,MAAM,GAAG,MAAM,IAAA,aAAS,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;YAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;YAE3C,IAAI,CAAC;gBACH,QAAQ,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;oBAC9B,KAAK,MAAM,CAAC;oBACZ,KAAK,KAAK;wBACR,MAAM,SAAS,CAAC,MAAmB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;wBACvD,MAAM;oBACR,QAAQ;oBACR,KAAK,MAAM;wBACT,MAAM,UAAU,CAAC,MAAgB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;wBACrD,MAAM;gBACV,CAAC;gBAED,OAAO;oBACL,MAAM,EAAE,SAAS;iBAClB,CAAC;YACJ,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO;oBACL,MAAM,EAAE,OAAO;oBACf,KAAK,EAAE,GAAG;iBACX,CAAC;YACJ,CAAC;oBAAS,CAAC;gBACT,MAAM,IAAA,iBAAS,EAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const uploadFileAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
protocol: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
3
|
+
host: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
+
port: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
5
|
+
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
6
|
+
password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
7
|
+
}>, {
|
|
8
|
+
fileName: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
9
|
+
fileContent: import("@activepieces/pieces-framework").FileProperty<true>;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uploadFileAction = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const __1 = require("../..");
|
|
7
|
+
const stream_1 = require("stream");
|
|
8
|
+
function uploadFileToFTP(client, fileName, fileContent) {
|
|
9
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
|
+
const remoteDirectory = fileName.substring(0, fileName.lastIndexOf('/'));
|
|
11
|
+
yield client.ensureDir(remoteDirectory);
|
|
12
|
+
yield client.uploadFrom(stream_1.Readable.from(fileContent.data), fileName);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function uploadFileToSFTP(client, fileName, fileContent) {
|
|
16
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const remotePathExists = yield client.exists(fileName);
|
|
18
|
+
if (!remotePathExists) {
|
|
19
|
+
const remoteDirectory = fileName.substring(0, fileName.lastIndexOf('/'));
|
|
20
|
+
yield client.mkdir(remoteDirectory, true);
|
|
21
|
+
}
|
|
22
|
+
yield client.put(fileContent.data, fileName);
|
|
23
|
+
yield client.end();
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.uploadFileAction = (0, pieces_framework_1.createAction)({
|
|
27
|
+
auth: __1.sftpAuth,
|
|
28
|
+
name: 'upload_file',
|
|
29
|
+
displayName: 'Upload File',
|
|
30
|
+
description: 'Upload a file to the given path.',
|
|
31
|
+
props: {
|
|
32
|
+
fileName: pieces_framework_1.Property.ShortText({
|
|
33
|
+
displayName: 'File Path',
|
|
34
|
+
required: true,
|
|
35
|
+
description: 'The path on the sftp server to store the file. e.g. `./myfolder/test.mp3`',
|
|
36
|
+
}),
|
|
37
|
+
fileContent: pieces_framework_1.Property.File({
|
|
38
|
+
displayName: 'File content',
|
|
39
|
+
required: true,
|
|
40
|
+
}),
|
|
41
|
+
},
|
|
42
|
+
run(context) {
|
|
43
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const client = yield (0, __1.getClient)(context.auth);
|
|
45
|
+
const fileName = context.propsValue['fileName'];
|
|
46
|
+
const fileContent = context.propsValue['fileContent'];
|
|
47
|
+
try {
|
|
48
|
+
switch (context.auth.protocol) {
|
|
49
|
+
case 'ftps':
|
|
50
|
+
case 'ftp':
|
|
51
|
+
yield uploadFileToFTP(client, fileName, fileContent);
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
case 'sftp':
|
|
55
|
+
yield uploadFileToSFTP(client, fileName, fileContent);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
status: 'success',
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
console.error(error);
|
|
64
|
+
return {
|
|
65
|
+
status: 'error',
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
yield (0, __1.endClient)(client);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=upload-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sftp/src/lib/actions/upload-file.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AAGxE,6BAAuD;AACvD,mCAAkC;AAElC,SAAe,eAAe,CAAC,MAAiB,EAAE,QAAgB,EAAE,WAA0B;;QAC5F,MAAM,eA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,GAAG,MAAM,IAAA,aAAS,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC7C,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YAChD,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;YAEtD,IAAI,CAAC;gBACH,QAAQ,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;oBAC9B,KAAK,MAAM,CAAC;oBACZ,KAAK,KAAK;wBACR,MAAM,eAAe,CAAC,MAAmB,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;wBAClE,MAAM;oBACR,QAAQ;oBACR,KAAK,MAAM;wBACT,MAAM,gBAAgB,CAAC,MAAgB,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;wBAChE,MAAM;gBACV,CAAC;gBACD,OAAO;oBACL,MAAM,EAAE,SAAS;iBAClB,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACrB,OAAO;oBACL,MAAM,EAAE,OAAO;iBAChB,CAAC;YACJ,CAAC;oBAAS,CAAC;gBACT,MAAM,IAAA,aAAS,EAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
2
|
export declare const newOrModifiedFile: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
3
|
+
protocol: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
3
4
|
host: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
5
|
port: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
5
6
|
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
@@ -8,6 +9,7 @@ export declare const newOrModifiedFile: import("@activepieces/pieces-framework")
|
|
|
8
9
|
path: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
9
10
|
ignoreHiddenFiles: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
10
11
|
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
12
|
+
protocol: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
11
13
|
host: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
12
14
|
port: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
13
15
|
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
@@ -16,6 +18,7 @@ export declare const newOrModifiedFile: import("@activepieces/pieces-framework")
|
|
|
16
18
|
path: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
17
19
|
ignoreHiddenFiles: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
18
20
|
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
21
|
+
protocol: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
19
22
|
host: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
20
23
|
port: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
21
24
|
username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
@@ -3,36 +3,42 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.newOrModifiedFile = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
-
const pieces_framework_2 = require("@activepieces/pieces-framework");
|
|
7
6
|
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
8
7
|
const __1 = require("../..");
|
|
9
8
|
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
10
|
-
|
|
9
|
+
function getModifyTime(file, protocol) {
|
|
10
|
+
return protocol === 'sftp' ?
|
|
11
|
+
file.modifyTime :
|
|
12
|
+
(0, dayjs_1.default)(file.modifiedAt).valueOf();
|
|
13
|
+
}
|
|
11
14
|
const polling = {
|
|
12
15
|
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
13
|
-
items: (
|
|
14
|
-
var _a;
|
|
15
|
-
const host = auth.host;
|
|
16
|
-
const port = auth.port;
|
|
17
|
-
const username = auth.username;
|
|
18
|
-
const password = auth.password;
|
|
19
|
-
const sftp = new ssh2_sftp_client_1.default();
|
|
16
|
+
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, propsValue, lastFetchEpochMS }) {
|
|
20
17
|
try {
|
|
21
|
-
yield
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
const client = yield (0, __1.getClient)(auth);
|
|
19
|
+
const files = yield client.list(propsValue.path);
|
|
20
|
+
if (auth.protocol === 'sftp') {
|
|
21
|
+
const sftpClient = client;
|
|
22
|
+
yield sftpClient.end();
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const ftpClient = client;
|
|
26
|
+
ftpClient.close();
|
|
27
|
+
}
|
|
28
|
+
const filteredFiles = files.filter(file => {
|
|
29
|
+
const modTime = getModifyTime(file, auth.protocol);
|
|
30
|
+
return (0, dayjs_1.default)(modTime).valueOf() > lastFetchEpochMS;
|
|
31
|
+
});
|
|
32
|
+
const finalFiles = propsValue.ignoreHiddenFiles ?
|
|
33
|
+
filteredFiles.filter(file => !file.name.startsWith('.')) :
|
|
34
|
+
filteredFiles;
|
|
35
|
+
return finalFiles.map(file => {
|
|
36
|
+
const modTime = getModifyTime(file, auth.protocol);
|
|
37
|
+
return {
|
|
38
|
+
data: Object.assign(Object.assign({}, file), { path: `${propsValue.path}/${file.name}` }),
|
|
39
|
+
epochMilliSeconds: (0, dayjs_1.default)(modTime).valueOf(),
|
|
40
|
+
};
|
|
26
41
|
});
|
|
27
|
-
let files = yield sftp.list(propsValue.path);
|
|
28
|
-
yield sftp.end();
|
|
29
|
-
files = files.filter((file) => (0, dayjs_1.default)(file.modifyTime).valueOf() > lastFetchEpochMS);
|
|
30
|
-
if (((_a = propsValue.ignoreHiddenFiles) !== null && _a !== void 0 ? _a : false) === true)
|
|
31
|
-
files = files.filter((file) => !file.name.startsWith('.'));
|
|
32
|
-
return files.map((file) => ({
|
|
33
|
-
data: Object.assign(Object.assign({}, file), { path: `${propsValue.path}/${file.name}` }),
|
|
34
|
-
epochMilliSeconds: (0, dayjs_1.default)(file.modifyTime).valueOf(),
|
|
35
|
-
}));
|
|
36
42
|
}
|
|
37
43
|
catch (err) {
|
|
38
44
|
return [];
|
|
@@ -58,35 +64,19 @@ exports.newOrModifiedFile = (0, pieces_framework_1.createTrigger)({
|
|
|
58
64
|
defaultValue: false,
|
|
59
65
|
}),
|
|
60
66
|
},
|
|
61
|
-
type:
|
|
67
|
+
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
62
68
|
onEnable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
-
yield pieces_common_1.pollingHelper.onEnable(polling,
|
|
64
|
-
auth: context.auth,
|
|
65
|
-
store: context.store,
|
|
66
|
-
propsValue: context.propsValue,
|
|
67
|
-
});
|
|
69
|
+
yield pieces_common_1.pollingHelper.onEnable(polling, context);
|
|
68
70
|
}),
|
|
69
71
|
onDisable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
70
|
-
yield pieces_common_1.pollingHelper.onDisable(polling,
|
|
71
|
-
auth: context.auth,
|
|
72
|
-
store: context.store,
|
|
73
|
-
propsValue: context.propsValue,
|
|
74
|
-
});
|
|
72
|
+
yield pieces_common_1.pollingHelper.onDisable(polling, context);
|
|
75
73
|
}),
|
|
76
74
|
run: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
-
return yield pieces_common_1.pollingHelper.poll(polling,
|
|
78
|
-
auth: context.auth,
|
|
79
|
-
store: context.store,
|
|
80
|
-
propsValue: context.propsValue,
|
|
81
|
-
});
|
|
75
|
+
return yield pieces_common_1.pollingHelper.poll(polling, context);
|
|
82
76
|
}),
|
|
83
77
|
test: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
-
return yield pieces_common_1.pollingHelper.test(polling,
|
|
85
|
-
auth: context.auth,
|
|
86
|
-
store: context.store,
|
|
87
|
-
propsValue: context.propsValue,
|
|
88
|
-
});
|
|
78
|
+
return yield pieces_common_1.pollingHelper.test(polling, context);
|
|
89
79
|
}),
|
|
90
|
-
sampleData:
|
|
80
|
+
sampleData: null,
|
|
91
81
|
});
|
|
92
82
|
//# sourceMappingURL=new-modified-file.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new-modified-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sftp/src/lib/triggers/new-modified-file.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"new-modified-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sftp/src/lib/triggers/new-modified-file.ts"],"names":[],"mappings":";;;;AAAA,qEAAgH;AAChH,+DAAqF;AACrF,6BAA4C;AAC5C,0DAA0B;AAI1B,SAAS,aAAa,CAAC,IAAmC,EAAE,QAAgB;IAC1E,OAAO,QAAQ,KAAK,MAAM,CAAC,CAAC;QACzB,IAAwB,CAAC,UAAU,CAAC,CAAC;QACtC,IAAA,eAAK,EAAE,IAAoB,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC;AACtD,CAAC;AAED,MAAM,OAAO,GAAkG;IAC7G,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,KAA+C,EAAE,oDAA1C,EAAE,IAAI,EAAE,UAAU,EAAE,gBAAgB,EAAE;QAClD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAA,a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