@activepieces/piece-sftp 0.2.4 → 0.2.6

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 CHANGED
@@ -1,20 +1,38 @@
1
1
  {
2
2
  "name": "@activepieces/piece-sftp",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "dependencies": {
5
- "@sinclair/typebox": "0.26.8",
6
- "axios": "^1.6.3",
5
+ "@anthropic-ai/sdk": "0.27.3",
6
+ "@sinclair/typebox": "0.34.11",
7
+ "axios": "1.7.8",
8
+ "axios-retry": "4.4.1",
9
+ "basic-ftp": "5.0.5",
7
10
  "dayjs": "1.11.9",
8
- "is-base64": "1.1.0",
9
- "lodash": "4.17.21",
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
- "@activepieces/pieces-common": "0.2.9",
14
- "@activepieces/pieces-framework": "0.7.24",
15
- "@activepieces/shared": "0.10.93",
18
+ "zod": "3.23.8",
19
+ "@activepieces/pieces-common": "0.2.37",
20
+ "@activepieces/pieces-framework": "0.7.42",
21
+ "@activepieces/shared": "0.10.133",
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,23 @@
1
+ import Client from 'ssh2-sftp-client';
2
+ import { Client as FTPClient } from 'basic-ftp';
3
+ export declare function getProtocolBackwardCompatibility(protocol: string | undefined): Promise<string>;
4
+ export declare function getClient<T extends Client | FTPClient>(auth: {
5
+ protocol: string | undefined;
6
+ host: string;
7
+ port: number;
8
+ username: string;
9
+ password: string;
10
+ }): Promise<T>;
11
+ export declare function endClient(client: Client | FTPClient, protocol: string | undefined): Promise<void>;
1
12
  export declare const sftpAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
13
+ protocol: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
2
14
  host: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
15
  port: import("@activepieces/pieces-framework").NumberProperty<true>;
4
16
  username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
5
17
  password: import("@activepieces/pieces-framework").SecretTextProperty<true>;
6
18
  }>;
7
- export declare const sftp: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<{
19
+ export declare const ftpSftp: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<{
20
+ protocol: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
8
21
  host: import("@activepieces/pieces-framework").ShortTextProperty<true>;
9
22
  port: import("@activepieces/pieces-framework").NumberProperty<true>;
10
23
  username: import("@activepieces/pieces-framework").ShortTextProperty<true>;
package/src/index.js CHANGED
@@ -1,49 +1,120 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sftp = exports.sftpAuth = void 0;
3
+ exports.ftpSftp = exports.sftpAuth = void 0;
4
+ exports.getProtocolBackwardCompatibility = getProtocolBackwardCompatibility;
5
+ exports.getClient = getClient;
6
+ exports.endClient = endClient;
4
7
  const tslib_1 = require("tslib");
5
8
  const pieces_framework_1 = require("@activepieces/pieces-framework");
6
9
  const shared_1 = require("@activepieces/shared");
7
10
  const ssh2_sftp_client_1 = tslib_1.__importDefault(require("ssh2-sftp-client"));
11
+ const basic_ftp_1 = require("basic-ftp");
8
12
  const create_file_1 = require("./lib/actions/create-file");
13
+ const upload_file_1 = require("./lib/actions/upload-file");
9
14
  const read_file_1 = require("./lib/actions/read-file");
10
15
  const new_modified_file_1 = require("./lib/triggers/new-modified-file");
16
+ const delete_folder_1 = require("./lib/actions/delete-folder");
17
+ const delete_file_1 = require("./lib/actions/delete-file");
18
+ const list_files_1 = require("./lib/actions/list-files");
19
+ const create_folder_1 = require("./lib/actions/create-folder");
20
+ const rename_file_or_folder_1 = require("./lib/actions/rename-file-or-folder");
21
+ function getProtocolBackwardCompatibility(protocol) {
22
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
+ if ((0, shared_1.isNil)(protocol)) {
24
+ return 'sftp';
25
+ }
26
+ return protocol;
27
+ });
28
+ }
29
+ function getClient(auth) {
30
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
31
+ const { protocol, host, port, username, password } = auth;
32
+ const protocolBackwardCompatibility = yield getProtocolBackwardCompatibility(protocol);
33
+ if (protocolBackwardCompatibility === 'sftp') {
34
+ const sftp = new ssh2_sftp_client_1.default();
35
+ yield sftp.connect({
36
+ host,
37
+ port,
38
+ username,
39
+ password,
40
+ timeout: 10000,
41
+ });
42
+ return sftp;
43
+ }
44
+ else {
45
+ const ftpClient = new basic_ftp_1.Client();
46
+ yield ftpClient.access({
47
+ host,
48
+ port,
49
+ user: username,
50
+ password,
51
+ secure: protocolBackwardCompatibility === 'ftps',
52
+ });
53
+ return ftpClient;
54
+ }
55
+ });
56
+ }
57
+ function endClient(client, protocol) {
58
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
59
+ const protocolBackwardCompatibility = yield getProtocolBackwardCompatibility(protocol);
60
+ if (protocolBackwardCompatibility === 'sftp') {
61
+ yield client.end();
62
+ }
63
+ else {
64
+ client.close();
65
+ }
66
+ });
67
+ }
11
68
  exports.sftpAuth = pieces_framework_1.PieceAuth.CustomAuth({
12
- description: 'Enter the authentication details',
13
69
  props: {
70
+ protocol: pieces_framework_1.Property.StaticDropdown({
71
+ displayName: 'Protocol',
72
+ description: 'The protocol to use',
73
+ required: false,
74
+ options: {
75
+ options: [
76
+ { value: 'sftp', label: 'SFTP' },
77
+ { value: 'ftp', label: 'FTP' },
78
+ { value: 'ftps', label: 'FTPS' }
79
+ ],
80
+ },
81
+ }),
14
82
  host: pieces_framework_1.Property.ShortText({
15
83
  displayName: 'Host',
16
- description: 'The host of the SFTP server',
84
+ description: 'The host of the server',
17
85
  required: true,
18
86
  }),
19
87
  port: pieces_framework_1.Property.Number({
20
88
  displayName: 'Port',
21
- description: 'The port of the SFTP server',
89
+ description: 'The port of the server',
22
90
  required: true,
23
91
  defaultValue: 22,
24
92
  }),
25
93
  username: pieces_framework_1.Property.ShortText({
26
94
  displayName: 'Username',
27
- description: 'The username of the SFTP server',
95
+ description: 'The username to authenticate with',
28
96
  required: true,
29
97
  }),
30
98
  password: pieces_framework_1.PieceAuth.SecretText({
31
99
  displayName: 'Password',
32
- description: 'The password of the SFTP server',
100
+ description: 'The password to authenticate with',
33
101
  required: true,
34
102
  }),
35
103
  },
36
- validate: ({ auth }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
37
- const { host, port, username, password } = auth;
38
- const sftp = new ssh2_sftp_client_1.default();
104
+ validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
105
+ let client = null;
106
+ const protocolBackwardCompatibility = yield getProtocolBackwardCompatibility(auth.protocol);
39
107
  try {
40
- yield sftp.connect({
41
- host,
42
- port,
43
- username,
44
- password,
45
- timeout: 10000,
46
- });
108
+ switch (protocolBackwardCompatibility) {
109
+ case 'sftp': {
110
+ client = yield getClient(auth);
111
+ break;
112
+ }
113
+ default: {
114
+ client = yield getClient(auth);
115
+ break;
116
+ }
117
+ }
47
118
  return {
48
119
  valid: true,
49
120
  };
@@ -55,20 +126,37 @@ exports.sftpAuth = pieces_framework_1.PieceAuth.CustomAuth({
55
126
  };
56
127
  }
57
128
  finally {
58
- yield sftp.end();
129
+ if (client) {
130
+ yield endClient(client, auth.protocol);
131
+ }
59
132
  }
60
133
  }),
61
134
  required: true,
62
135
  });
63
- exports.sftp = (0, pieces_framework_1.createPiece)({
64
- displayName: 'SFTP',
65
- description: 'Secure file transfer protocol',
66
- minimumSupportedRelease: '0.7.1',
136
+ exports.ftpSftp = (0, pieces_framework_1.createPiece)({
137
+ displayName: 'FTP/SFTP',
138
+ description: 'Connect to FTP, FTPS or SFTP servers',
139
+ minimumSupportedRelease: '0.30.0',
67
140
  logoUrl: 'https://cdn.activepieces.com/pieces/sftp.svg',
68
141
  categories: [shared_1.PieceCategory.CORE, shared_1.PieceCategory.DEVELOPER_TOOLS],
69
- authors: ["Abdallah-Alwarawreh", "kishanprmr", "AbdulTheActivePiecer", "khaledmashaly", "abuaboud"],
142
+ authors: [
143
+ 'Abdallah-Alwarawreh',
144
+ 'kishanprmr',
145
+ 'AbdulTheActivePiecer',
146
+ 'khaledmashaly',
147
+ 'abuaboud',
148
+ ],
70
149
  auth: exports.sftpAuth,
71
- actions: [create_file_1.createFile, read_file_1.readFileContent],
150
+ actions: [
151
+ create_file_1.createFile,
152
+ upload_file_1.uploadFileAction,
153
+ read_file_1.readFileContent,
154
+ delete_file_1.deleteFileAction,
155
+ create_folder_1.createFolderAction,
156
+ delete_folder_1.deleteFolderAction,
157
+ list_files_1.listFolderContentsAction,
158
+ rename_file_or_folder_1.renameFileOrFolderAction,
159
+ ],
72
160
  triggers: [new_modified_file_1.newOrModifiedFile],
73
161
  });
74
162
  //# 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":";;;;AAAA,qEAIwC;AACxC,iDAAqD;AACrD,gFAAsC;AACtC,2DAAuD;AACvD,uDAA0D;AAC1D,wEAAqE;AACxD,QAAA,QAAQ,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC3C,WAAW,EAAE,kCAAkC;IAC/C,KAAK,EAAE;QACL,IAAI,EAAE,2BAAQ,CA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AO,GAAG,IAAA,8BAAW,EAAC;IACjC,WAAW,EAAE,UAAU;IACvB,WAAW,EAAE,sCAAsC;IACnD,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,8CAA8C;IACvD,UAAU,EAAE,CAAC,sBAAa,CAAC,IAAI,EAAE,sBAAa,CAAC,eAAe,CAAC;IAC/D,OAAO,EAAE;QACP,qBAAqB;QACrB,YAAY;QACZ,sBAAsB;QACtB,eAAe;QACf,UAAU;KACX;IACD,IAAI,EAAE,gBAAQ;IACd,OAAO,EAAE;QACP,wBAAU;QACV,8BAAgB;QAChB,2BAAe;QACf,8BAAgB;QAChB,kCAAkB;QAClB,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, false>;
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,35 @@ 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 sftp = new ssh2_sftp_client_1.default();
50
+ const protocolBackwardCompatibility = yield (0, __1.getProtocolBackwardCompatibility)(context.auth.protocol);
51
+ const client = yield (0, __1.getClient)(context.auth);
32
52
  try {
33
- yield sftp.connect({
34
- host,
35
- port,
36
- username,
37
- password,
38
- });
39
- const remotePathExists = yield sftp.exists(fileName);
40
- if (!remotePathExists) {
41
- // Extract the directory path from the fileName
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
53
+ switch (protocolBackwardCompatibility) {
54
+ case 'ftps':
55
+ case 'ftp':
56
+ yield createFileWithFTP(client, fileName, fileContent);
57
+ break;
58
+ default:
59
+ case 'sftp':
60
+ yield createFileWithSFTP(client, fileName, fileContent);
61
+ break;
46
62
  }
47
- yield sftp.put(Buffer.from(fileContent), fileName);
48
- yield sftp.end();
49
63
  return {
50
64
  status: 'success',
51
65
  };
52
66
  }
53
67
  catch (err) {
68
+ console.error(err);
54
69
  return {
55
70
  status: 'error',
56
71
  error: err,
57
72
  };
58
73
  }
74
+ finally {
75
+ yield (0, __1.endClient)(client, context.auth.protocol);
76
+ }
59
77
  });
60
78
  },
61
79
  });
@@ -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;AACxE,gFAAsC;AACtC,6BAAiC;AAEpB,QAAA,UAAU,GAAG,IAAA,+BAAY,EAAC;IACrC,IAAI,EAAE,YAAQ;IACd,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,uBAAuB;IACpC,WAAW,EAAE,qCAAqC;IAClD,KAAK,EAAE;QACL,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,WAAW;YACxB,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,WAAW,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC7B,WAAW,EAAE,cAAc;YAC3B,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;YAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;YAC/B,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;YACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;YACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YAChD,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;YACtD,MAAM,IAAI,GAAG,IAAI,0BAAM,EAAE,CAAC;YAE1B,IAAI;gBACF,MAAM,IAAI,CAAC,OAAO,CAAC;oBACjB,IAAI;oBACJ,IAAI;oBACJ,QAAQ;oBACR,QAAQ;iBACT,CAAC,CAAC;gBAEH,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACrD,IAAI,CAAC,gBAAgB,EAAE;oBACrB,+CAA+C;oBAC/C,MAAM,eAAe,GAAG,QAAQ,CAAC,SAAS,CACxC,CAAC,EACD,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAC1B,CAAC;oBAEF,2CAA2C;oBAC3C,MAAM,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,oFAAoF;oBAE7H,oGAAoG;iBACrG;gBAED,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,CAAC;gBACnD,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;gBAEjB,OAAO;oBACL,MAAM,EAAE,SAAS;iBAClB,CAAC;aACH;YAAC,OAAO,GAAG,EAAE;gBACZ,OAAO;oBACL,MAAM,EAAE,OAAO;oBACf,KAAK,EAAE,GAAG;iBACX,CAAC;aACH;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"create-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sftp/src/lib/actions/create-file.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AAGxE,6BAAyF;AACzF,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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AAa,CAAC,CAAC;YACtD,MAAM,6BAA6B,GAAG,MAAM,IAAA,oCAAgC,EAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACpG,MAAM,MAAM,GAAG,MAAM,IAAA,aAAS,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAE7C,IAAI,CAAC;gBACD,QAAQ,6BAA6B,EAAE,CAAC;oBACpC,KAAK,MAAM,CAAC;oBACZ,KAAK,KAAK;wBACN,MAAM,iBAAiB,CAAC,MAAmB,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;wBACpE,MAAM;oBACV,QAAQ;oBACR,KAAK,MAAM;wBACP,MAAM,kBAAkB,CAAC,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,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACnD,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, false>;
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,59 @@
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
+ const protocolBackwardCompatibility = yield (0, index_1.getProtocolBackwardCompatibility)(context.auth.protocol);
32
+ try {
33
+ switch (protocolBackwardCompatibility) {
34
+ case 'ftps':
35
+ case 'ftp':
36
+ yield client.ensureDir(directoryPath);
37
+ break;
38
+ default:
39
+ case 'sftp':
40
+ yield client.mkdir(directoryPath, recursive);
41
+ break;
42
+ }
43
+ return {
44
+ status: 'success',
45
+ };
46
+ }
47
+ catch (err) {
48
+ return {
49
+ status: 'error',
50
+ error: err,
51
+ };
52
+ }
53
+ finally {
54
+ yield (0, index_1.endClient)(client, context.auth.protocol);
55
+ }
56
+ });
57
+ },
58
+ });
59
+ //# sourceMappingURL=create-folder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-folder.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sftp/src/lib/actions/create-folder.ts"],"names":[],"mappings":";;;;AAAE,uCAA+F;AACjG,qEAAwE;AAI3D,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC7C,IAAI,EAAE,gBAAQ;IACd,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,eAAe;IAC5B,WAAW,EAAE,iCAAiC;IAC9C,KAAK,EAAE;QACL,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,aAAa;YAC1B,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,kGAAkG;SAChH,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YAC3B,WAAW,EAAE,WAAW;YACxB,YAAY,EAAE,KAAK;YACnB,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,+DAA+D;SAC7E,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;;YACf,MAAM,MAAM,GAAG,MAAM,IAAA,iBAAS,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;YACxD,MAAM,6BAA6B,GAAG,MAAM,IAAA,wCAAgC,EAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACpG,IAAI,CAAC;gBACH,QAAQ,6BAA6B,EAAE,CAAC;oBACtC,KAAK,MAAM,CAAC;oBACZ,KAAK,KAAK;wBACR,MAAO,MAAoB,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;wBACrD,MAAM;oBACR,QAAQ;oBACR,KAAK,MAAM;wBACT,MAAO,MAAiB,CAAC,KAAK,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;wBACzD,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,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjD,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, false>;
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,62 @@
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
+ const protocolBackwardCompatibility = yield (0, __1.getProtocolBackwardCompatibility)(context.auth.protocol);
34
+ try {
35
+ switch (protocolBackwardCompatibility) {
36
+ case 'ftps':
37
+ case 'ftp':
38
+ yield deleteFileFromFTP(client, filePath);
39
+ break;
40
+ default:
41
+ case 'sftp':
42
+ yield deleteFileFromSFTP(client, filePath);
43
+ break;
44
+ }
45
+ return {
46
+ status: 'success',
47
+ };
48
+ }
49
+ catch (err) {
50
+ console.error(err);
51
+ return {
52
+ status: 'error',
53
+ error: err,
54
+ };
55
+ }
56
+ finally {
57
+ yield (0, __1.endClient)(client, context.auth.protocol);
58
+ }
59
+ });
60
+ },
61
+ });
62
+ //# 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,6BAAyF;AAIzF,SAAe,iBAAiB,CAAC,MAAiB,EAAE,QAAgB;;QAClE,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;CAAA;AAED,SAAe,kBAAkB,CAAC,MAAc,EAAE,QAAgB;;QAChE,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;CAAA;AAEY,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,YAAQ;IACd,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,+BAA+B;IAC5C,KAAK,EAAE;QACL,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,WAAW;YACxB,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,2DAA2D;SACzE,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;YACf,MAAM,MAAM,GAAG,MAAM,IAAA,aAAS,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC7C,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;YAC7C,MAAM,6BAA6B,GAAG,MAAM,IAAA,oCAAgC,EAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACpG,IAAI,CAAC;gBACH,QAAQ,6BAA6B,EAAE,CAAC;oBACtC,KAAK,MAAM,CAAC;oBACZ,KAAK,KAAK;wBACR,MAAM,iBAAiB,CAAC,MAAmB,EAAE,QAAQ,CAAC,CAAC;wBACvD,MAAM;oBACR,QAAQ;oBACR,KAAK,MAAM;wBACT,MAAM,kBAAkB,CAAC,MAAgB,EAAE,QAAQ,CAAC,CAAC;wBACrD,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,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +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, false>;
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,75 @@
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
+ const protocolBackwardCompatibility = yield (0, __1.getProtocolBackwardCompatibility)(context.auth.protocol);
47
+ try {
48
+ switch (protocolBackwardCompatibility) {
49
+ case 'ftps':
50
+ case 'ftp':
51
+ yield deleteFolderFTP(client, directoryPath, recursive);
52
+ break;
53
+ default:
54
+ case 'sftp':
55
+ yield deleteFolderSFTP(client, directoryPath, recursive);
56
+ break;
57
+ }
58
+ return {
59
+ status: 'success',
60
+ };
61
+ }
62
+ catch (err) {
63
+ console.error(err);
64
+ return {
65
+ status: 'error',
66
+ error: err,
67
+ };
68
+ }
69
+ finally {
70
+ yield (0, __1.endClient)(client, context.auth.protocol);
71
+ }
72
+ });
73
+ },
74
+ });
75
+ //# 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,6BAAyF;AAEzF,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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9 @@
1
+ export declare const listFolderContentsAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
+ protocol: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false>;
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,81 @@
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
+ const protocolBackwardCompatibility = yield (0, __1.getProtocolBackwardCompatibility)(context.auth.protocol);
51
+ try {
52
+ let contents;
53
+ switch (protocolBackwardCompatibility) {
54
+ case 'ftps':
55
+ case 'ftp':
56
+ contents = yield listFTP(client, directoryPath);
57
+ break;
58
+ default:
59
+ case 'sftp':
60
+ contents = yield listSFTP(client, directoryPath);
61
+ break;
62
+ }
63
+ return {
64
+ status: 'success',
65
+ contents: contents,
66
+ };
67
+ }
68
+ catch (err) {
69
+ return {
70
+ status: 'error',
71
+ contents: null,
72
+ error: err,
73
+ };
74
+ }
75
+ finally {
76
+ yield (0, index_1.endClient)(client, context.auth.protocol);
77
+ }
78
+ });
79
+ },
80
+ });
81
+ //# 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,6BAAoE;AAEpE,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,CAAC,CAAC,CAAC,GAA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MAAgB,EAAE,aAAa,CAAC,CAAC;wBAC3D,MAAM;gBACV,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,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjD,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, false>;
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 ssh2_sftp_client_1 = tslib_1.__importDefault(require("ssh2-sftp-client"));
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,40 @@ 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
- const { host, port, username, password } = context.auth;
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
- yield sftp.end();
35
- return {
36
- file: yield context.files.write({
37
- fileName: fileName,
38
- data: fileContent,
39
- }),
40
- };
46
+ const protocolBackwardCompatibility = yield (0, __1.getProtocolBackwardCompatibility)(context.auth.protocol);
47
+ try {
48
+ let fileContent;
49
+ switch (protocolBackwardCompatibility) {
50
+ case 'ftps':
51
+ case 'ftp':
52
+ fileContent = yield readFTP(client, filePath);
53
+ break;
54
+ default:
55
+ case 'sftp':
56
+ fileContent = yield readSFTP(client, filePath);
57
+ break;
58
+ }
59
+ return {
60
+ file: yield context.files.write({
61
+ fileName: fileName,
62
+ data: fileContent,
63
+ }),
64
+ };
65
+ }
66
+ catch (err) {
67
+ return {
68
+ success: false,
69
+ error: err,
70
+ };
71
+ }
72
+ finally {
73
+ yield (0, index_1.endClient)(client, context.auth.protocol);
74
+ }
41
75
  });
42
76
  },
43
77
  });
@@ -1 +1 @@
1
- {"version":3,"file":"read-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/sftp/src/lib/actions/read-file.ts"],"names":[],"mappings":";;;;AAAA,uCAAuC;AACvC,qEAAwE;AACxE,gFAAsC;AAEzB,QAAA,eAAe,GAAG,IAAA,+BAAY,EAAC;IAC1C,IAAI,EAAE,gBAAQ;IACd,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,mBAAmB;IAChC,WAAW,EAAE,4BAA4B;IACzC,KAAK,EAAE;QACL,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,WAAW;YACxB,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG,CAAC,OAAO;;;YACf,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;YACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YAChD,MAAM,IAAI,GAAG,IAAI,0BAAM,EAAE,CAAC;YAE1B,MAAM,IAAI,CAAC,OAAO,CAAC;gBACjB,IAAI;gBACJ,IAAI;gBACJ,QAAQ;gBACR,QAAQ;gBACR,YAAY,EAAE,KAAK;aACpB,CAAC,CAAC;YAEH,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC7C,MAAM,QAAQ,GAAG,MAAA,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,mCAAI,QAAQ,CAAC;YACvD,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;YAEjB,OAAO;gBACL,IAAI,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;oBAC9B,QAAQ,EAAE,QAAQ;oBAClB,IAAI,EAAE,WAAqB;iBAC5B,CAAC;aACH,CAAC;;KACH;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"read-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community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CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,mCAAI,QAAQ,CAAC;YACvD,MAAM,6BAA6B,GAAG,MAAM,IAAA,oCAAgC,EAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACpG,IAAI,CAAC;gBACH,IAAI,WAAmB,CAAC;gBACxB,QAAQ,6BAA6B,EAAE,CAAC;oBACtC,KAAK,MAAM,CAAC;oBACZ,KAAK,KAAK;wBACR,WAAW,GAAG,MAAM,OAAO,CAAC,MAAmB,EAAE,QAAQ,CAAC,CAAC;wBAC3D,MAAM;oBACR,QAAQ;oBACR,KAAK,MAAM;wBACT,WAAW,GAAG,MAAM,QAAQ,CAAC,MAAgB,EAAE,QAAQ,CAAC,CAAC;wBACzD,MAAM;gBACV,CAAC;gBAED,OAAO;oBACL,IAAI,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;wBAC9B,QAAQ,EAAE,QAAQ;wBAClB,IAAI,EAAE,WAAW;qBAClB,CAAC;iBACH,CAAC;YACJ,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,GAAG;iBACX,CAAC;YACJ,CAAC;oBAAS,CAAC;gBACT,MAAM,IAAA,iBAAS,EAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjD,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, false>;
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,74 @@
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
+ const protocolBackwardCompatibility = yield (0, __1.getProtocolBackwardCompatibility)(context.auth.protocol);
47
+ try {
48
+ switch (protocolBackwardCompatibility) {
49
+ case 'ftps':
50
+ case 'ftp':
51
+ yield renameFTP(client, oldPath, newPath);
52
+ break;
53
+ default:
54
+ case 'sftp':
55
+ yield renameSFTP(client, oldPath, newPath);
56
+ break;
57
+ }
58
+ return {
59
+ status: 'success',
60
+ };
61
+ }
62
+ catch (err) {
63
+ return {
64
+ status: 'error',
65
+ error: err,
66
+ };
67
+ }
68
+ finally {
69
+ yield (0, index_1.endClient)(client, context.auth.protocol);
70
+ }
71
+ });
72
+ },
73
+ });
74
+ //# 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,6BAAoE;AACpE,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,C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}
@@ -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, false>;
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,75 @@
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
+ const protocolBackwardCompatibility = yield (0, __1.getProtocolBackwardCompatibility)(context.auth.protocol);
48
+ try {
49
+ switch (protocolBackwardCompatibility) {
50
+ case 'ftps':
51
+ case 'ftp':
52
+ yield uploadFileToFTP(client, fileName, fileContent);
53
+ break;
54
+ default:
55
+ case 'sftp':
56
+ yield uploadFileToSFTP(client, fileName, fileContent);
57
+ break;
58
+ }
59
+ return {
60
+ status: 'success',
61
+ };
62
+ }
63
+ catch (error) {
64
+ console.error(error);
65
+ return {
66
+ status: 'error',
67
+ };
68
+ }
69
+ finally {
70
+ yield (0, __1.endClient)(client, context.auth.protocol);
71
+ }
72
+ });
73
+ },
74
+ });
75
+ //# 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,6BAAyF;AACzF,mCAAkC;AAElC,SAAe,eAAe,CAAC,MAAiB,EAAE,QAAgB,EAAE,WAA0B;;QAC5F,MAAM,eAAe,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;QACzE,MAAM,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;QACxC,MAAM,MAAM,CAAC,UAAU,CAAC,iBAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;I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AI,CAAC,QAAQ,CAAC,CAAC;YACpG,IAAI,CAAC;gBACH,QAAQ,6BAA6B,EAAE,CAAC;oBACtC,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,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjD,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, false>;
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, false>;
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, false>;
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,40 +3,45 @@ 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
- const ssh2_sftp_client_1 = tslib_1.__importDefault(require("ssh2-sftp-client"));
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: ({ auth, propsValue, lastFetchEpochMS }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
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 }) {
17
+ let client = null;
20
18
  try {
21
- yield sftp.connect({
22
- host,
23
- port,
24
- username,
25
- password,
19
+ const protocolBackwardCompatibility = yield (0, __1.getProtocolBackwardCompatibility)(auth.protocol);
20
+ client = yield (0, __1.getClient)(auth);
21
+ const files = yield client.list(propsValue.path);
22
+ const filteredFiles = files.filter(file => {
23
+ const modTime = getModifyTime(file, protocolBackwardCompatibility);
24
+ return (0, dayjs_1.default)(modTime).valueOf() > lastFetchEpochMS;
25
+ });
26
+ const finalFiles = propsValue.ignoreHiddenFiles ?
27
+ filteredFiles.filter(file => !file.name.startsWith('.')) :
28
+ filteredFiles;
29
+ return finalFiles.map(file => {
30
+ const modTime = getModifyTime(file, protocolBackwardCompatibility);
31
+ return {
32
+ data: Object.assign(Object.assign({}, file), { path: `${propsValue.path}/${file.name}` }),
33
+ epochMilliSeconds: (0, dayjs_1.default)(modTime).valueOf(),
34
+ };
26
35
  });
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
36
  }
37
37
  catch (err) {
38
38
  return [];
39
39
  }
40
+ finally {
41
+ if (client) {
42
+ yield (0, __1.endClient)(client, auth.protocol);
43
+ }
44
+ }
40
45
  }),
41
46
  };
42
47
  exports.newOrModifiedFile = (0, pieces_framework_1.createTrigger)({
@@ -58,35 +63,19 @@ exports.newOrModifiedFile = (0, pieces_framework_1.createTrigger)({
58
63
  defaultValue: false,
59
64
  }),
60
65
  },
61
- type: pieces_framework_2.TriggerStrategy.POLLING,
66
+ type: pieces_framework_1.TriggerStrategy.POLLING,
62
67
  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
- });
68
+ yield pieces_common_1.pollingHelper.onEnable(polling, context);
68
69
  }),
69
70
  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
- });
71
+ yield pieces_common_1.pollingHelper.onDisable(polling, context);
75
72
  }),
76
73
  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
- });
74
+ return yield pieces_common_1.pollingHelper.poll(polling, context);
82
75
  }),
83
76
  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
- });
77
+ return yield pieces_common_1.pollingHelper.test(polling, context);
89
78
  }),
90
- sampleData: {},
79
+ sampleData: null,
91
80
  });
92
81
  //# 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,qEAIwC;AACxC,qEAAiE;AACjE,+DAIqC;AACrC,6BAAiC;AACjC,0DAA0B;AAC1B,gFAAsC;AAEtC,MAAM,OAAO,GAGT;IACF,QAAQ,EAAE,8BAAc,CAAC,SAAS;IAClC,KAAK,EAAE,CAAO,EAAE,IAAI,EAAE,UAAU,EAAE,g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;SAC/B,CAAC,CAAC;IACL,CAAC,CAAA;IACD,IAAI,EAAE,CAAO,OAAO,EAAE,EAAE;QACtB,OAAO,MAAM,6BAAa,CAAC,IAAI,CAAC,OAAO,EAAE;YACvC,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B,CAAC,CAAC;IACL,CAAC,CAAA;IACD,UAAU,EAAE,EAAE;CACf,CAAC,CAAC"}
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,6BAAyF;AACzF,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,MAAM,GAA8B,IAAI,CAAC;QAC7C,IAAI,CAAC;YACH,MAAM,6BAA6B,GAAG,MAAM,IAAA,oCAAgC,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5F,MAAM,GAAG,MAAM,IAAA,aAAS,EAAC,IAAI,CAAC,CAAC;YAC/B,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAEjD,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBACxC,MAAM,OAAO,GAAG,aAAa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