@edirect/sftp-client 11.0.48 → 11.0.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -72,15 +72,15 @@ export class ReportService {
72
72
 
73
73
  ## Connection Options (`ISFTPClientOptions`)
74
74
 
75
- | Option | Type | Required | Description |
76
- |--------|------|----------|-------------|
77
- | `host` | `string` | Yes | SFTP server hostname or IP |
78
- | `port` | `string` | Yes | SFTP server port (usually `'22'`) |
79
- | `username` | `string` | Yes | SSH username |
80
- | `password` | `string` | No | Password authentication |
81
- | `privateKey` | `string \| Buffer` | No | Private key for key-based authentication |
82
- | `passphrase` | `string` | No | Passphrase for the private key |
83
- | `encoding` | `string` | No | File encoding |
75
+ | Option | Type | Required | Description |
76
+ | ------------ | ------------------ | -------- | ---------------------------------------- |
77
+ | `host` | `string` | Yes | SFTP server hostname or IP |
78
+ | `port` | `string` | Yes | SFTP server port (usually `'22'`) |
79
+ | `username` | `string` | Yes | SSH username |
80
+ | `password` | `string` | No | Password authentication |
81
+ | `privateKey` | `string \| Buffer` | No | Private key for key-based authentication |
82
+ | `passphrase` | `string` | No | Passphrase for the private key |
83
+ | `encoding` | `string` | No | File encoding |
84
84
 
85
85
  Either `password` or `privateKey` must be provided.
86
86
 
@@ -88,15 +88,15 @@ Either `password` or `privateKey` must be provided.
88
88
 
89
89
  ### `SftpClientService`
90
90
 
91
- | Method | Signature | Description |
92
- |--------|-----------|-------------|
93
- | `upload` | `(options, dataToUpload: string \| Buffer, fileName: string): Promise<void>` | Upload content to `fileName` on the SFTP server |
94
- | `download` | `(options, fileName: string, downloadPath: string \| WritableStream): Promise<void>` | Download `fileName` to a local path or writable stream |
95
- | `delete` | `(options, deletePath: string): Promise<void>` | Delete a file at the given path |
96
- | `rename` | `(options, fromPath: string, toPath: string): Promise<void>` | Rename a file |
97
- | `posixRename` | `(options, fromPath: string, toPath: string): Promise<void>` | Rename using POSIX atomic rename (server-side) |
98
- | `listFiles` | `(options, path: string, orderByModifiedDate?: 'ASC' \| 'DESC'): Promise<string[]>` | List filenames in a directory, optionally sorted by modification time |
99
- | `getFileContent` | `(options, filePath: string): Promise<string>` | Read and return file content as a UTF-8 string |
91
+ | Method | Signature | Description |
92
+ | ---------------- | ------------------------------------------------------------------------------------ | --------------------------------------------------------------------- |
93
+ | `upload` | `(options, dataToUpload: string \| Buffer, fileName: string): Promise<void>` | Upload content to `fileName` on the SFTP server |
94
+ | `download` | `(options, fileName: string, downloadPath: string \| WritableStream): Promise<void>` | Download `fileName` to a local path or writable stream |
95
+ | `delete` | `(options, deletePath: string): Promise<void>` | Delete a file at the given path |
96
+ | `rename` | `(options, fromPath: string, toPath: string): Promise<void>` | Rename a file |
97
+ | `posixRename` | `(options, fromPath: string, toPath: string): Promise<void>` | Rename using POSIX atomic rename (server-side) |
98
+ | `listFiles` | `(options, path: string, orderByModifiedDate?: 'ASC' \| 'DESC'): Promise<string[]>` | List filenames in a directory, optionally sorted by modification time |
99
+ | `getFileContent` | `(options, filePath: string): Promise<string>` | Read and return file content as a UTF-8 string |
100
100
 
101
101
  > Each method opens a new SFTP connection, performs the operation, and closes the connection. This avoids stale connection issues in long-running services.
102
102
 
@@ -130,6 +130,6 @@ await sftp.upload(
130
130
  passphrase: process.env.SSH_PASSPHRASE,
131
131
  },
132
132
  fileContent,
133
- '/uploads/report.csv'
133
+ '/uploads/report.csv',
134
134
  );
135
135
  ```
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edirect/sftp-client",
3
- "version": "11.0.48",
3
+ "version": "11.0.46",
4
4
  "main": "./dist/src/index.js",
5
5
  "types": "./dist/src/index.d.ts",
6
6
  "exports": {
@@ -16,12 +16,12 @@
16
16
  "dist"
17
17
  ],
18
18
  "dependencies": {
19
- "@nestjs/common": "^11.1.15",
19
+ "@nestjs/common": "^11.1.12",
20
20
  "ssh2-sftp-client": "^12.0.1",
21
21
  "tslib": "^2.8.1"
22
22
  },
23
23
  "devDependencies": {
24
- "@types/node": "^25.3.3",
24
+ "@types/node": "^25.0.10",
25
25
  "@types/ssh2-sftp-client": "^9.0.6"
26
26
  },
27
27
  "type": "commonjs"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edirect/sftp-client",
3
- "version": "11.0.48",
3
+ "version": "11.0.50",
4
4
  "packageScope": "@edirect",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -17,12 +17,12 @@
17
17
  "dist"
18
18
  ],
19
19
  "dependencies": {
20
- "@nestjs/common": "^11.1.15",
21
- "ssh2-sftp-client": "^12.0.1",
20
+ "@nestjs/common": "^11.1.16",
21
+ "ssh2-sftp-client": "^12.1.0",
22
22
  "tslib": "^2.8.1"
23
23
  },
24
24
  "devDependencies": {
25
- "@types/node": "^25.3.3",
25
+ "@types/node": "^25.4.0",
26
26
  "@types/ssh2-sftp-client": "^9.0.6"
27
27
  },
28
28
  "nx": {
@@ -42,4 +42,4 @@
42
42
  }
43
43
  }
44
44
  }
45
- }
45
+ }
package/dist/README.md DELETED
@@ -1,135 +0,0 @@
1
- # @edirect/sftp-client
2
-
3
- SFTP client module for eDirect NestJS applications. Provides a `SftpClientService` with methods for uploading, downloading, listing, renaming, and deleting files on SFTP servers — backed by `ssh2-sftp-client`.
4
-
5
- ## Features
6
-
7
- - Upload files (string content or Buffer)
8
- - Download files to a local path or writable stream
9
- - List directory contents with optional sort by modification date
10
- - Read file content as string
11
- - Rename files (`rename` and `posixRename`)
12
- - Delete files
13
- - Connection options support both password and private key authentication
14
- - NestJS module — injectable via `SftpClientModule`
15
-
16
- ## Installation
17
-
18
- ```sh
19
- pnpm add @edirect/sftp-client
20
- # or
21
- npm install @edirect/sftp-client
22
- ```
23
-
24
- ## Setup
25
-
26
- ### Register `SftpClientModule` in your AppModule
27
-
28
- ```ts
29
- import { Module } from '@nestjs/common';
30
- import { SftpClientModule } from '@edirect/sftp-client';
31
-
32
- @Module({
33
- imports: [SftpClientModule],
34
- })
35
- export class AppModule {}
36
- ```
37
-
38
- ### Inject and use `SftpClientService`
39
-
40
- ```ts
41
- import { Injectable } from '@nestjs/common';
42
- import { SftpClientService } from '@edirect/sftp-client';
43
-
44
- const SFTP_OPTIONS = {
45
- host: process.env.SFTP_HOST,
46
- username: process.env.SFTP_USERNAME,
47
- password: process.env.SFTP_PASSWORD,
48
- port: process.env.SFTP_PORT ?? '22',
49
- };
50
-
51
- @Injectable()
52
- export class ReportService {
53
- constructor(private readonly sftp: SftpClientService) {}
54
-
55
- async uploadReport(content: string, filename: string): Promise<void> {
56
- await this.sftp.upload(SFTP_OPTIONS, content, `/reports/${filename}`);
57
- }
58
-
59
- async downloadReport(filename: string, localPath: string): Promise<void> {
60
- await this.sftp.download(SFTP_OPTIONS, `/reports/${filename}`, localPath);
61
- }
62
-
63
- async listReports(): Promise<string[]> {
64
- return this.sftp.listFiles(SFTP_OPTIONS, '/reports', 'DESC');
65
- }
66
-
67
- async readLatestReport(filename: string): Promise<string> {
68
- return this.sftp.getFileContent(SFTP_OPTIONS, `/reports/${filename}`);
69
- }
70
- }
71
- ```
72
-
73
- ## Connection Options (`ISFTPClientOptions`)
74
-
75
- | Option | Type | Required | Description |
76
- |--------|------|----------|-------------|
77
- | `host` | `string` | Yes | SFTP server hostname or IP |
78
- | `port` | `string` | Yes | SFTP server port (usually `'22'`) |
79
- | `username` | `string` | Yes | SSH username |
80
- | `password` | `string` | No | Password authentication |
81
- | `privateKey` | `string \| Buffer` | No | Private key for key-based authentication |
82
- | `passphrase` | `string` | No | Passphrase for the private key |
83
- | `encoding` | `string` | No | File encoding |
84
-
85
- Either `password` or `privateKey` must be provided.
86
-
87
- ## API
88
-
89
- ### `SftpClientService`
90
-
91
- | Method | Signature | Description |
92
- |--------|-----------|-------------|
93
- | `upload` | `(options, dataToUpload: string \| Buffer, fileName: string): Promise<void>` | Upload content to `fileName` on the SFTP server |
94
- | `download` | `(options, fileName: string, downloadPath: string \| WritableStream): Promise<void>` | Download `fileName` to a local path or writable stream |
95
- | `delete` | `(options, deletePath: string): Promise<void>` | Delete a file at the given path |
96
- | `rename` | `(options, fromPath: string, toPath: string): Promise<void>` | Rename a file |
97
- | `posixRename` | `(options, fromPath: string, toPath: string): Promise<void>` | Rename using POSIX atomic rename (server-side) |
98
- | `listFiles` | `(options, path: string, orderByModifiedDate?: 'ASC' \| 'DESC'): Promise<string[]>` | List filenames in a directory, optionally sorted by modification time |
99
- | `getFileContent` | `(options, filePath: string): Promise<string>` | Read and return file content as a UTF-8 string |
100
-
101
- > Each method opens a new SFTP connection, performs the operation, and closes the connection. This avoids stale connection issues in long-running services.
102
-
103
- ## Environment Variables
104
-
105
- The module does not read environment variables directly — connection options are passed per-call. A recommended pattern is to load them from `@edirect/config`:
106
-
107
- ```ts
108
- import { ConfigService } from '@edirect/config';
109
-
110
- const options = {
111
- host: configService.get('SFTP_HOST'),
112
- port: configService.get('SFTP_PORT') ?? '22',
113
- username: configService.get('SFTP_USERNAME'),
114
- password: configService.get('SFTP_PASSWORD'),
115
- privateKey: configService.get('SFTP_PRIVATE_KEY'),
116
- };
117
- ```
118
-
119
- ## Key-Based Authentication
120
-
121
- ```ts
122
- import fs from 'fs';
123
-
124
- await sftp.upload(
125
- {
126
- host: 'sftp.example.com',
127
- port: '22',
128
- username: 'deploy',
129
- privateKey: fs.readFileSync('/path/to/id_rsa'),
130
- passphrase: process.env.SSH_PASSPHRASE,
131
- },
132
- fileContent,
133
- '/uploads/report.csv'
134
- );
135
- ```