hetzner-storage-sdk 1.0.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.
- package/LICENSE +21 -0
- package/README.md +539 -0
- package/dist/HetznerStorageClient.d.ts +103 -0
- package/dist/HetznerStorageClient.js +202 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +56 -0
- package/dist/providers/BaseStorageProvider.d.ts +73 -0
- package/dist/providers/BaseStorageProvider.js +13 -0
- package/dist/providers/ObjectStorageProvider.d.ts +114 -0
- package/dist/providers/ObjectStorageProvider.js +285 -0
- package/dist/providers/StorageBoxProvider.d.ts +96 -0
- package/dist/providers/StorageBoxProvider.js +312 -0
- package/dist/providers/StorageShareProvider.d.ts +112 -0
- package/dist/providers/StorageShareProvider.js +253 -0
- package/dist/types/index.d.ts +247 -0
- package/dist/types/index.js +2 -0
- package/dist/utils/OcsApiClient.d.ts +41 -0
- package/dist/utils/OcsApiClient.js +144 -0
- package/dist/utils/RobotApiClient.d.ts +48 -0
- package/dist/utils/RobotApiClient.js +98 -0
- package/dist/utils/S3ApiClient.d.ts +28 -0
- package/dist/utils/S3ApiClient.js +326 -0
- package/dist/utils/env-config.d.ts +45 -0
- package/dist/utils/env-config.js +112 -0
- package/package.json +47 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OBJECT_STORAGE_ENV = exports.STORAGE_SHARE_ENV = exports.STORAGE_BOX_ENV = void 0;
|
|
4
|
+
exports.loadStorageBoxEnv = loadStorageBoxEnv;
|
|
5
|
+
exports.loadStorageShareEnv = loadStorageShareEnv;
|
|
6
|
+
exports.loadObjectStorageEnv = loadObjectStorageEnv;
|
|
7
|
+
exports.mergeWithEnv = mergeWithEnv;
|
|
8
|
+
const dotenv_1 = require("dotenv");
|
|
9
|
+
(0, dotenv_1.config)(); // Load environment variables from .env file
|
|
10
|
+
/**
|
|
11
|
+
* Environment variable names for Storage Box configuration
|
|
12
|
+
*/
|
|
13
|
+
exports.STORAGE_BOX_ENV = {
|
|
14
|
+
USERNAME: 'HETZNER_STORAGE_BOX_USERNAME',
|
|
15
|
+
PASSWORD: 'HETZNER_STORAGE_BOX_PASSWORD',
|
|
16
|
+
PROTOCOL: 'HETZNER_STORAGE_BOX_PROTOCOL',
|
|
17
|
+
STORAGE_BOX_ID: 'HETZNER_STORAGE_BOX_ID',
|
|
18
|
+
ROBOT_USERNAME: 'HETZNER_ROBOT_USERNAME',
|
|
19
|
+
ROBOT_PASSWORD: 'HETZNER_ROBOT_PASSWORD',
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Environment variable names for Storage Share configuration
|
|
23
|
+
*/
|
|
24
|
+
exports.STORAGE_SHARE_ENV = {
|
|
25
|
+
USERNAME: 'HETZNER_STORAGE_SHARE_USERNAME',
|
|
26
|
+
PASSWORD: 'HETZNER_STORAGE_SHARE_PASSWORD',
|
|
27
|
+
INSTANCE: 'HETZNER_STORAGE_SHARE_INSTANCE',
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Environment variable names for Object Storage configuration
|
|
31
|
+
*/
|
|
32
|
+
exports.OBJECT_STORAGE_ENV = {
|
|
33
|
+
ACCESS_KEY_ID: 'HETZNER_OBJECT_STORAGE_ACCESS_KEY_ID',
|
|
34
|
+
SECRET_ACCESS_KEY: 'HETZNER_OBJECT_STORAGE_SECRET_ACCESS_KEY',
|
|
35
|
+
REGION: 'HETZNER_OBJECT_STORAGE_REGION',
|
|
36
|
+
BUCKET: 'HETZNER_OBJECT_STORAGE_BUCKET',
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Load Storage Box configuration from environment variables
|
|
40
|
+
*/
|
|
41
|
+
function loadStorageBoxEnv() {
|
|
42
|
+
const config = {
|
|
43
|
+
type: 'box',
|
|
44
|
+
};
|
|
45
|
+
if (process.env[exports.STORAGE_BOX_ENV.USERNAME]) {
|
|
46
|
+
config.username = process.env[exports.STORAGE_BOX_ENV.USERNAME];
|
|
47
|
+
}
|
|
48
|
+
if (process.env[exports.STORAGE_BOX_ENV.PASSWORD]) {
|
|
49
|
+
config.password = process.env[exports.STORAGE_BOX_ENV.PASSWORD];
|
|
50
|
+
}
|
|
51
|
+
if (process.env[exports.STORAGE_BOX_ENV.PROTOCOL]) {
|
|
52
|
+
config.protocol = process.env[exports.STORAGE_BOX_ENV.PROTOCOL];
|
|
53
|
+
}
|
|
54
|
+
if (process.env[exports.STORAGE_BOX_ENV.STORAGE_BOX_ID]) {
|
|
55
|
+
config.storageBoxId = process.env[exports.STORAGE_BOX_ENV.STORAGE_BOX_ID];
|
|
56
|
+
}
|
|
57
|
+
if (process.env[exports.STORAGE_BOX_ENV.ROBOT_USERNAME]) {
|
|
58
|
+
config.robotUsername = process.env[exports.STORAGE_BOX_ENV.ROBOT_USERNAME];
|
|
59
|
+
}
|
|
60
|
+
if (process.env[exports.STORAGE_BOX_ENV.ROBOT_PASSWORD]) {
|
|
61
|
+
config.robotPassword = process.env[exports.STORAGE_BOX_ENV.ROBOT_PASSWORD];
|
|
62
|
+
}
|
|
63
|
+
return config;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Load Storage Share configuration from environment variables
|
|
67
|
+
*/
|
|
68
|
+
function loadStorageShareEnv() {
|
|
69
|
+
const config = {
|
|
70
|
+
type: 'share',
|
|
71
|
+
};
|
|
72
|
+
if (process.env[exports.STORAGE_SHARE_ENV.USERNAME]) {
|
|
73
|
+
config.username = process.env[exports.STORAGE_SHARE_ENV.USERNAME];
|
|
74
|
+
}
|
|
75
|
+
if (process.env[exports.STORAGE_SHARE_ENV.PASSWORD]) {
|
|
76
|
+
config.password = process.env[exports.STORAGE_SHARE_ENV.PASSWORD];
|
|
77
|
+
}
|
|
78
|
+
if (process.env[exports.STORAGE_SHARE_ENV.INSTANCE]) {
|
|
79
|
+
config.instance = process.env[exports.STORAGE_SHARE_ENV.INSTANCE];
|
|
80
|
+
}
|
|
81
|
+
return config;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Load Object Storage configuration from environment variables
|
|
85
|
+
*/
|
|
86
|
+
function loadObjectStorageEnv() {
|
|
87
|
+
const config = {
|
|
88
|
+
type: 'object',
|
|
89
|
+
};
|
|
90
|
+
if (process.env[exports.OBJECT_STORAGE_ENV.ACCESS_KEY_ID]) {
|
|
91
|
+
config.accessKeyId = process.env[exports.OBJECT_STORAGE_ENV.ACCESS_KEY_ID];
|
|
92
|
+
}
|
|
93
|
+
if (process.env[exports.OBJECT_STORAGE_ENV.SECRET_ACCESS_KEY]) {
|
|
94
|
+
config.secretAccessKey = process.env[exports.OBJECT_STORAGE_ENV.SECRET_ACCESS_KEY];
|
|
95
|
+
}
|
|
96
|
+
if (process.env[exports.OBJECT_STORAGE_ENV.REGION]) {
|
|
97
|
+
config.region = process.env[exports.OBJECT_STORAGE_ENV.REGION];
|
|
98
|
+
}
|
|
99
|
+
if (process.env[exports.OBJECT_STORAGE_ENV.BUCKET]) {
|
|
100
|
+
config.bucket = process.env[exports.OBJECT_STORAGE_ENV.BUCKET];
|
|
101
|
+
}
|
|
102
|
+
return config;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Merge provided config with environment variables (provided config takes precedence)
|
|
106
|
+
*/
|
|
107
|
+
function mergeWithEnv(provided, envConfig) {
|
|
108
|
+
return {
|
|
109
|
+
...envConfig,
|
|
110
|
+
...provided,
|
|
111
|
+
};
|
|
112
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hetzner-storage-sdk",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "TypeScript SDK for Hetzner Storage Box, Storage Share, and Object Storage",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"keywords": [
|
|
11
|
+
"hetzner",
|
|
12
|
+
"storage",
|
|
13
|
+
"webdav",
|
|
14
|
+
"nextcloud",
|
|
15
|
+
"s3",
|
|
16
|
+
"object-storage",
|
|
17
|
+
"typescript"
|
|
18
|
+
],
|
|
19
|
+
"author": "Sajankumar Vijayan <work@sajankumarv.com>",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@aws-sdk/client-s3": "^3.500.0",
|
|
23
|
+
"@aws-sdk/s3-request-presigner": "^3.500.0",
|
|
24
|
+
"axios": "^1.6.0",
|
|
25
|
+
"dotenv": "^17.2.4",
|
|
26
|
+
"ssh2-sftp-client": "^10.0.3",
|
|
27
|
+
"webdav": "^5.3.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^20.0.0",
|
|
31
|
+
"@types/ssh2-sftp-client": "^9.0.6",
|
|
32
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
33
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
34
|
+
"eslint": "^8.0.0",
|
|
35
|
+
"jest": "^29.0.0",
|
|
36
|
+
"prettier": "^3.0.0",
|
|
37
|
+
"typescript": "^5.0.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"example": "ts-node examples/usage-examples.ts",
|
|
42
|
+
"dev": "tsc --watch",
|
|
43
|
+
"test": "echo \"No tests yet\"",
|
|
44
|
+
"lint": "eslint src --ext .ts",
|
|
45
|
+
"format": "prettier --write \"src/**/*.ts\""
|
|
46
|
+
}
|
|
47
|
+
}
|