@simplysm/storage 14.0.22 → 14.0.24
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 +2 -2
- package/README.md +0 -134
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/storage",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.24",
|
|
4
4
|
"description": "심플리즘 패키지 - 저장소 (node)",
|
|
5
5
|
"author": "심플리즘",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"basic-ftp": "^5.2.0",
|
|
22
22
|
"ssh2-sftp-client": "^12.1.1",
|
|
23
|
-
"@simplysm/core-common": "14.0.
|
|
23
|
+
"@simplysm/core-common": "14.0.24"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/ssh2-sftp-client": "^9.0.6"
|
package/README.md
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
# @simplysm/storage
|
|
2
|
-
|
|
3
|
-
Storage client library for FTP, FTPS, and SFTP file operations.
|
|
4
|
-
|
|
5
|
-
Platform: Node.js.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install @simplysm/storage
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## API Overview
|
|
14
|
-
|
|
15
|
-
### Types
|
|
16
|
-
|
|
17
|
-
#### StorageConnConfig
|
|
18
|
-
|
|
19
|
-
Connection configuration for storage clients.
|
|
20
|
-
|
|
21
|
-
| Field | Type | Description |
|
|
22
|
-
|---|---|---|
|
|
23
|
-
| `host` | `string` | Server hostname or IP address |
|
|
24
|
-
| `port?` | `number` | Server port (protocol default if omitted) |
|
|
25
|
-
| `user?` | `string` | Username |
|
|
26
|
-
| `password?` | `string` | Password |
|
|
27
|
-
|
|
28
|
-
#### FileInfo
|
|
29
|
-
|
|
30
|
-
File/directory entry returned by `list()`.
|
|
31
|
-
|
|
32
|
-
| Field | Type | Description |
|
|
33
|
-
|---|---|---|
|
|
34
|
-
| `name` | `string` | File or directory name |
|
|
35
|
-
| `isFile` | `boolean` | `true` if this entry is a file, `false` if it is a directory |
|
|
36
|
-
|
|
37
|
-
#### StorageProtocol
|
|
38
|
-
|
|
39
|
-
```typescript
|
|
40
|
-
type StorageProtocol = "ftp" | "ftps" | "sftp";
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
#### StorageClient (interface)
|
|
44
|
-
|
|
45
|
-
Common interface implemented by all storage clients.
|
|
46
|
-
|
|
47
|
-
| Method | Signature | Description |
|
|
48
|
-
|---|---|---|
|
|
49
|
-
| `connect` | `(config: StorageConnConfig) => Promise<void>` | Connect to the server |
|
|
50
|
-
| `mkdir` | `(dirPath: string) => Promise<void>` | Create directory (recursive) |
|
|
51
|
-
| `rename` | `(fromPath: string, toPath: string) => Promise<void>` | Rename a file or directory |
|
|
52
|
-
| `list` | `(dirPath: string) => Promise<FileInfo[]>` | List directory contents |
|
|
53
|
-
| `readFile` | `(filePath: string) => Promise<Bytes>` | Read file contents |
|
|
54
|
-
| `exists` | `(filePath: string) => Promise<boolean>` | Check if file or directory exists |
|
|
55
|
-
| `put` | `(localPathOrBuffer: string \| Bytes, storageFilePath: string) => Promise<void>` | Upload a local file path or byte data to remote path |
|
|
56
|
-
| `uploadDir` | `(fromPath: string, toPath: string) => Promise<void>` | Upload entire local directory to remote path |
|
|
57
|
-
| `remove` | `(filePath: string) => Promise<void>` | Remove a file |
|
|
58
|
-
| `close` | `() => Promise<void>` | Close the connection. Safe to call multiple times. |
|
|
59
|
-
|
|
60
|
-
### Clients
|
|
61
|
-
|
|
62
|
-
#### FtpStorageClient
|
|
63
|
-
|
|
64
|
-
FTP/FTPS client. Implements `StorageClient`. Uses `basic-ftp` internally.
|
|
65
|
-
|
|
66
|
-
```typescript
|
|
67
|
-
constructor(secure?: boolean)
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
| Parameter | Type | Default | Description |
|
|
71
|
-
|---|---|---|---|
|
|
72
|
-
| `secure` | `boolean` | `false` | Set `true` for FTPS |
|
|
73
|
-
|
|
74
|
-
All methods from `StorageClient` are implemented. Prefer using `StorageFactory.connect` over direct instantiation.
|
|
75
|
-
|
|
76
|
-
#### SftpStorageClient
|
|
77
|
-
|
|
78
|
-
SFTP client. Implements `StorageClient`. Uses `ssh2-sftp-client` internally.
|
|
79
|
-
|
|
80
|
-
```typescript
|
|
81
|
-
constructor()
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Authentication priority when `password` is not provided:
|
|
85
|
-
1. SSH private key (`~/.ssh/id_ed25519`) + SSH agent
|
|
86
|
-
2. SSH agent only (fallback when key parsing fails)
|
|
87
|
-
|
|
88
|
-
All methods from `StorageClient` are implemented. Prefer using `StorageFactory.connect` over direct instantiation.
|
|
89
|
-
|
|
90
|
-
### Factory
|
|
91
|
-
|
|
92
|
-
#### StorageFactory
|
|
93
|
-
|
|
94
|
-
Static factory class for creating and managing storage connections.
|
|
95
|
-
|
|
96
|
-
##### Static Methods
|
|
97
|
-
|
|
98
|
-
| Method | Signature | Description |
|
|
99
|
-
|---|---|---|
|
|
100
|
-
| `connect` | `<R>(type: StorageProtocol, config: StorageConnConfig, fn: (storage: StorageClient) => R \| Promise<R>) => Promise<R>` | Connect to storage, execute callback, and automatically close the connection. The connection is closed even if the callback throws. |
|
|
101
|
-
|
|
102
|
-
## Usage
|
|
103
|
-
|
|
104
|
-
### Recommended: StorageFactory (auto-managed connection)
|
|
105
|
-
|
|
106
|
-
```typescript
|
|
107
|
-
import { StorageFactory } from "@simplysm/storage";
|
|
108
|
-
|
|
109
|
-
const files = await StorageFactory.connect("sftp", {
|
|
110
|
-
host: "example.com",
|
|
111
|
-
user: "deploy",
|
|
112
|
-
}, async (client) => {
|
|
113
|
-
await client.mkdir("/remote/path");
|
|
114
|
-
await client.put("/local/file.txt", "/remote/file.txt");
|
|
115
|
-
return client.list("/remote/path");
|
|
116
|
-
});
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### Direct client usage
|
|
120
|
-
|
|
121
|
-
```typescript
|
|
122
|
-
import { SftpStorageClient } from "@simplysm/storage";
|
|
123
|
-
|
|
124
|
-
const client = new SftpStorageClient();
|
|
125
|
-
await client.connect({ host: "example.com", user: "deploy" });
|
|
126
|
-
try {
|
|
127
|
-
const exists = await client.exists("/remote/file.txt");
|
|
128
|
-
if (exists) {
|
|
129
|
-
const data = await client.readFile("/remote/file.txt");
|
|
130
|
-
}
|
|
131
|
-
} finally {
|
|
132
|
-
await client.close();
|
|
133
|
-
}
|
|
134
|
-
```
|