@activepieces/piece-sftp 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/package.json +15 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +13 -0
- package/src/index.js.map +1 -0
- package/src/lib/actions/create-file.d.ts +1 -0
- package/src/lib/actions/create-file.js +83 -0
- package/src/lib/actions/create-file.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@activepieces/piece-sftp",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@sinclair/typebox": "0.26.8",
|
|
6
|
+
"lodash": "4.17.21",
|
|
7
|
+
"nanoid": "3.3.4",
|
|
8
|
+
"ssh2-sftp-client": "9.1.0",
|
|
9
|
+
"@activepieces/pieces-framework": "0.3.27",
|
|
10
|
+
"@activepieces/shared": "0.3.46",
|
|
11
|
+
"tslib": "2.5.3"
|
|
12
|
+
},
|
|
13
|
+
"main": "./src/index.js",
|
|
14
|
+
"types": "./src/index.d.ts"
|
|
15
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sftp: import("@activepieces/pieces-framework").Piece;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sftp = void 0;
|
|
4
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
5
|
+
const create_file_1 = require("./lib/actions/create-file");
|
|
6
|
+
exports.sftp = (0, pieces_framework_1.createPiece)({
|
|
7
|
+
displayName: "SFTP",
|
|
8
|
+
logoUrl: "https://cdn.activepieces.com/pieces/sftp.png",
|
|
9
|
+
authors: ["Abdallah-Alwarawreh"],
|
|
10
|
+
actions: [create_file_1.createFile],
|
|
11
|
+
triggers: [],
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/sftp/src/index.ts"],"names":[],"mappings":";;;AACA,qEAA6D;AAC7D,2DAAuD;AAE1C,QAAA,IAAI,GAAG,IAAA,8BAAW,EAAC;IAC9B,WAAW,EAAE,MAAM;IACnB,OAAO,EAAE,8CAA8C;IACvD,OAAO,EAAE,CAAC,qBAAqB,CAAC;IAChC,OAAO,EAAE,CAAC,wBAAU,CAAC;IACrB,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createFile: import("@activepieces/pieces-framework").Action;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFile = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const ssh2_sftp_client_1 = tslib_1.__importDefault(require("ssh2-sftp-client"));
|
|
7
|
+
exports.createFile = (0, pieces_framework_1.createAction)({
|
|
8
|
+
name: 'create_file',
|
|
9
|
+
displayName: 'Create new file',
|
|
10
|
+
description: 'Create a new file in the given path',
|
|
11
|
+
props: {
|
|
12
|
+
// host, port, username, password
|
|
13
|
+
authentication: pieces_framework_1.Property.CustomAuth({
|
|
14
|
+
displayName: 'Authentication',
|
|
15
|
+
description: 'Enter the authentication details',
|
|
16
|
+
props: {
|
|
17
|
+
host: pieces_framework_1.Property.ShortText({
|
|
18
|
+
displayName: 'Host',
|
|
19
|
+
description: 'The host of the SFTP server',
|
|
20
|
+
required: true,
|
|
21
|
+
}),
|
|
22
|
+
port: pieces_framework_1.Property.Number({
|
|
23
|
+
displayName: 'Port',
|
|
24
|
+
description: 'The port of the SFTP server',
|
|
25
|
+
required: true,
|
|
26
|
+
defaultValue: 22,
|
|
27
|
+
}),
|
|
28
|
+
username: pieces_framework_1.Property.ShortText({
|
|
29
|
+
displayName: 'Username',
|
|
30
|
+
description: 'The username of the SFTP server',
|
|
31
|
+
required: true,
|
|
32
|
+
}),
|
|
33
|
+
password: pieces_framework_1.Property.SecretText({
|
|
34
|
+
displayName: 'Password',
|
|
35
|
+
description: 'The password of the SFTP server',
|
|
36
|
+
required: true,
|
|
37
|
+
}),
|
|
38
|
+
},
|
|
39
|
+
required: true
|
|
40
|
+
}),
|
|
41
|
+
fileName: pieces_framework_1.Property.ShortText({
|
|
42
|
+
displayName: 'File Path',
|
|
43
|
+
description: 'The name of the file to create',
|
|
44
|
+
required: true,
|
|
45
|
+
}),
|
|
46
|
+
fileContent: pieces_framework_1.Property.LongText({
|
|
47
|
+
displayName: 'File content',
|
|
48
|
+
description: 'The content of the file to create',
|
|
49
|
+
required: true,
|
|
50
|
+
}),
|
|
51
|
+
},
|
|
52
|
+
run(context) {
|
|
53
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const host = context.propsValue['authentication'].host;
|
|
55
|
+
const port = context.propsValue['authentication'].port;
|
|
56
|
+
const username = context.propsValue['authentication'].username;
|
|
57
|
+
const password = context.propsValue['authentication'].password;
|
|
58
|
+
const fileName = context.propsValue['fileName'];
|
|
59
|
+
const fileContent = context.propsValue['fileContent'];
|
|
60
|
+
const sftp = new ssh2_sftp_client_1.default();
|
|
61
|
+
try {
|
|
62
|
+
yield sftp.connect({
|
|
63
|
+
host,
|
|
64
|
+
port,
|
|
65
|
+
username,
|
|
66
|
+
password
|
|
67
|
+
});
|
|
68
|
+
yield sftp.put(Buffer.from(fileContent), fileName);
|
|
69
|
+
yield sftp.end();
|
|
70
|
+
return {
|
|
71
|
+
status: 'success'
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
return {
|
|
76
|
+
status: 'error',
|
|
77
|
+
error: err
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=create-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-file.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/sftp/src/lib/actions/create-file.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,gFAAqC;AAExB,QAAA,UAAU,GAAG,IAAA,+BAAY,EAAC;IACnC,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,qCAAqC;IAClD,KAAK,EAAE;QACH,iCAAiC;QACjC,cAAc,EAAE,2BAAQ,CAAC,UAAU,CAAC;YAChC,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,kCAAkC;YAC/C,KAAK,EAAE;gBACH,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;oBACrB,WAAW,EAAE,MAAM;oBACnB,WAAW,EAAE,6BAA6B;oBAC1C,QAAQ,EAAE,IAAI;iBACjB,CAAC;gBACF,IAAI,EAAE,2BAAQ,CAAC,MAAM,CAAC;oBAClB,WAAW,EAAE,MAAM;oBACnB,WAAW,EAAE,6BAA6B;oBAC1C,QAAQ,EAAE,IAAI;oBACd,YAAY,EAAE,EAAE;iBACnB,CAAC;gBACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;oBACzB,WAAW,EAAE,UAAU;oBACvB,WAAW,EAAE,iCAAiC;oBAC9C,QAAQ,EAAE,IAAI;iBACjB,CAAC;gBACF,QAAQ,EAAE,2BAAQ,CAAC,UAAU,CAAC;oBAC1B,WAAW,EAAE,UAAU;oBACvB,WAAW,EAAE,iCAAiC;oBAC9C,QAAQ,EAAE,IAAI;iBACjB,CAAC;aACL;YACD,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACzB,WAAW,E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