@cellaware/utils 9.4.5 → 9.5.1
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.
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export declare const INTEGRATION_VISIBILITY_PRIVATE = "private";
|
|
2
2
|
export declare const INTEGRATION_VISIBILITY_PUBLIC = "public";
|
|
3
|
+
export declare const INTEGRATION_VENDOR_GENERIC = "generic";
|
|
3
4
|
export declare const INTEGRATION_VENDOR_TEAMS = "teams";
|
|
4
5
|
export declare const INTEGRATION_VENDOR_SLACK = "slack";
|
|
5
6
|
export declare const INTEGRATION_TYPE_WEBHOOK = "webhook";
|
|
7
|
+
export declare const INTEGRATION_TYPE_SFTP = "sftp";
|
|
6
8
|
export interface SubscriptionIntegration {
|
|
7
9
|
integrationId: string;
|
|
8
10
|
name: string;
|
|
@@ -10,14 +12,17 @@ export interface SubscriptionIntegration {
|
|
|
10
12
|
visibility: string;
|
|
11
13
|
readonly: boolean;
|
|
12
14
|
/**
|
|
13
|
-
* `teams` | `slack`
|
|
15
|
+
* `generic` | `teams` | `slack`
|
|
14
16
|
*/
|
|
15
17
|
vendor: string;
|
|
16
18
|
/**
|
|
17
|
-
* `webhook`
|
|
19
|
+
* `webhook` | `sftp`
|
|
18
20
|
*/
|
|
19
21
|
type: string;
|
|
20
22
|
url: string;
|
|
23
|
+
port?: number;
|
|
24
|
+
username?: string;
|
|
25
|
+
password?: string;
|
|
21
26
|
clientId: string;
|
|
22
27
|
userId: string;
|
|
23
28
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export const INTEGRATION_VISIBILITY_PRIVATE = 'private';
|
|
2
2
|
export const INTEGRATION_VISIBILITY_PUBLIC = 'public';
|
|
3
|
+
export const INTEGRATION_VENDOR_GENERIC = 'generic';
|
|
3
4
|
export const INTEGRATION_VENDOR_TEAMS = 'teams';
|
|
4
5
|
export const INTEGRATION_VENDOR_SLACK = 'slack';
|
|
5
6
|
export const INTEGRATION_TYPE_WEBHOOK = 'webhook';
|
|
7
|
+
export const INTEGRATION_TYPE_SFTP = 'sftp';
|
|
6
8
|
export function initSubscriptionIntegration() {
|
|
7
9
|
return {
|
|
8
10
|
integrationId: '',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function uploadSftpFile(url: string, port: number, username: string, password: string, filename: string, data: string | Buffer): Promise<void>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import Client from 'ssh2-sftp-client';
|
|
2
|
+
export async function uploadSftpFile(url, port, username, password, filename, data) {
|
|
3
|
+
const sftp = new Client();
|
|
4
|
+
// SFTP expects a hostname, not a URL.
|
|
5
|
+
// Example: `https://securetransfer.example.com/` -> `securetransfer.example.com`
|
|
6
|
+
const host = url
|
|
7
|
+
.trim()
|
|
8
|
+
.replace(/^https?:\/\//i, '')
|
|
9
|
+
.replace(/\/+$/, '');
|
|
10
|
+
if (!host) {
|
|
11
|
+
throw new Error('SFTP: Host is required');
|
|
12
|
+
}
|
|
13
|
+
if (!username) {
|
|
14
|
+
throw new Error('SFTP: Username is required');
|
|
15
|
+
}
|
|
16
|
+
if (!password) {
|
|
17
|
+
throw new Error('SFTP: Password is required');
|
|
18
|
+
}
|
|
19
|
+
if (!filename) {
|
|
20
|
+
throw new Error('SFTP: Filename is required');
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
await sftp.connect({
|
|
24
|
+
host,
|
|
25
|
+
port: port || 22,
|
|
26
|
+
username,
|
|
27
|
+
password
|
|
28
|
+
});
|
|
29
|
+
const fileData = Buffer.isBuffer(data)
|
|
30
|
+
? data
|
|
31
|
+
: Buffer.from(data, 'utf8');
|
|
32
|
+
await sftp.put(fileData, filename);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
throw new Error(`SFTP: Failed to upload "${filename}" to SFTP host "${host}": ${err.message}`);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
try {
|
|
39
|
+
await sftp.end();
|
|
40
|
+
}
|
|
41
|
+
catch { }
|
|
42
|
+
}
|
|
43
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cellaware/utils",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.5.1",
|
|
4
4
|
"description": "Cellaware Utilities for Node.js",
|
|
5
5
|
"author": "Cellaware Technologies",
|
|
6
6
|
"type": "module",
|
|
@@ -21,9 +21,11 @@
|
|
|
21
21
|
"@azure/functions": "^4.5.1",
|
|
22
22
|
"@azure/storage-blob": "^12.16.0",
|
|
23
23
|
"dotenv": "^16.3.1",
|
|
24
|
-
"langchain": "^0.2.19"
|
|
24
|
+
"langchain": "^0.2.19",
|
|
25
|
+
"ssh2-sftp-client": "^12.1.1"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
28
|
+
"@types/ssh2-sftp-client": "^9.0.6",
|
|
27
29
|
"typescript": "^5.3.2"
|
|
28
30
|
}
|
|
29
31
|
}
|