@e-mc/cloud 0.13.1 → 0.13.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 -7
- package/index.js +44 -46
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.13.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.13.2/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { IHost, IScopeOrigin } from "./index";
|
|
@@ -180,12 +180,12 @@ const rows = await instance.getDatabaseRows({ service: "aws-v3", credential: "ma
|
|
|
180
180
|
|
|
181
181
|
## References
|
|
182
182
|
|
|
183
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
184
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
185
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
186
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
187
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
188
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
183
|
+
- https://www.unpkg.com/@e-mc/types@0.13.2/lib/asset.d.ts
|
|
184
|
+
- https://www.unpkg.com/@e-mc/types@0.13.2/lib/cloud.d.ts
|
|
185
|
+
- https://www.unpkg.com/@e-mc/types@0.13.2/lib/core.d.ts
|
|
186
|
+
- https://www.unpkg.com/@e-mc/types@0.13.2/lib/db.d.ts
|
|
187
|
+
- https://www.unpkg.com/@e-mc/types@0.13.2/lib/logger.d.ts
|
|
188
|
+
- https://www.unpkg.com/@e-mc/types@0.13.2/lib/settings.d.ts
|
|
189
189
|
|
|
190
190
|
## LICENSE
|
|
191
191
|
|
package/index.js
CHANGED
|
@@ -673,33 +673,32 @@ class Cloud extends core_1.ClientDb {
|
|
|
673
673
|
if (this.aborted) {
|
|
674
674
|
return (0, types_1.createAbortError)(true);
|
|
675
675
|
}
|
|
676
|
-
let handler;
|
|
677
676
|
try {
|
|
678
|
-
handler = this.getUploadHandler(service, credential).bind(this);
|
|
677
|
+
const handler = this.getUploadHandler(service, credential).bind(this);
|
|
678
|
+
return new Promise((resolve, reject) => {
|
|
679
|
+
const flags = upload.flags || 0;
|
|
680
|
+
handler({ bucket, upload, buffer: upload.buffer || ((flags & 1) === 0 && (flags & 2) === 0 && (flags & 4) === 0 ? fs.readFileSync(localUri) : Buffer.alloc(0)), localUri }, async (err, value) => {
|
|
681
|
+
if (err) {
|
|
682
|
+
reject(errorObject(err, service, "Upload failed"));
|
|
683
|
+
}
|
|
684
|
+
else if ((0, types_1.isString)(value)) {
|
|
685
|
+
if (beforeResolve) {
|
|
686
|
+
await beforeResolve(value);
|
|
687
|
+
}
|
|
688
|
+
this.addLog(4, 'uploadObject: ' + bucket, service, value);
|
|
689
|
+
this.uploaded.push(value);
|
|
690
|
+
resolve(value);
|
|
691
|
+
}
|
|
692
|
+
else {
|
|
693
|
+
reject((0, types_1.errorMessage)(service, "Upload failed"));
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
});
|
|
679
697
|
}
|
|
680
698
|
catch (err) {
|
|
681
699
|
this.formatMessage(64, service, ["Upload function not supported", bucket], localUri, Cloud.optionsLogMessage('WARN'));
|
|
682
700
|
throw err;
|
|
683
701
|
}
|
|
684
|
-
return new Promise((resolve, reject) => {
|
|
685
|
-
const flags = upload.flags || 0;
|
|
686
|
-
handler({ bucket, upload, buffer: upload.buffer || ((flags & 1) === 0 && (flags & 2) === 0 && (flags & 4) === 0 ? fs.readFileSync(localUri) : Buffer.alloc(0)), localUri }, async (err, value) => {
|
|
687
|
-
if (err) {
|
|
688
|
-
reject(errorObject(err, service, "Upload failed"));
|
|
689
|
-
}
|
|
690
|
-
else if ((0, types_1.isString)(value)) {
|
|
691
|
-
if (beforeResolve) {
|
|
692
|
-
await beforeResolve(value);
|
|
693
|
-
}
|
|
694
|
-
this.addLog(4, 'uploadObject: ' + bucket, service, value);
|
|
695
|
-
this.uploaded.push(value);
|
|
696
|
-
resolve(value);
|
|
697
|
-
}
|
|
698
|
-
else {
|
|
699
|
-
reject((0, types_1.errorMessage)(service, "Upload failed"));
|
|
700
|
-
}
|
|
701
|
-
});
|
|
702
|
-
});
|
|
703
702
|
}
|
|
704
703
|
async downloadObject(service, credential, bucket, download, beforeResolve) {
|
|
705
704
|
if (this.aborted) {
|
|
@@ -708,37 +707,36 @@ class Cloud extends core_1.ClientDb {
|
|
|
708
707
|
if ((service === 'gcp' || service === 'gcloud') && (0, types_1.isPlainObject)(credential)) {
|
|
709
708
|
credential.storageBucket ||= bucket;
|
|
710
709
|
}
|
|
711
|
-
let handler;
|
|
712
710
|
try {
|
|
713
|
-
handler = this.getDownloadHandler(service, credential).bind(this);
|
|
711
|
+
const handler = this.getDownloadHandler(service, credential).bind(this);
|
|
712
|
+
return new Promise((resolve, reject) => {
|
|
713
|
+
handler({ bucket, download }, async (err, value) => {
|
|
714
|
+
if (err) {
|
|
715
|
+
reject(errorObject(err, service, "Download failed"));
|
|
716
|
+
}
|
|
717
|
+
else if (value) {
|
|
718
|
+
if (beforeResolve) {
|
|
719
|
+
const output = await beforeResolve(value);
|
|
720
|
+
if ((0, types_1.isString)(output)) {
|
|
721
|
+
value = output;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
if ((0, types_1.isString)(value) && path.isAbsolute(value)) {
|
|
725
|
+
this.addLog(4, 'downloadObject: ' + bucket, service, value);
|
|
726
|
+
this.downloaded.push(value);
|
|
727
|
+
}
|
|
728
|
+
resolve(value);
|
|
729
|
+
}
|
|
730
|
+
else {
|
|
731
|
+
reject((0, types_1.errorMessage)(service, "Download failed"));
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
});
|
|
714
735
|
}
|
|
715
736
|
catch (err) {
|
|
716
737
|
this.formatMessage(64, service, ["Download function not supported", bucket], Cloud.joinPath(download.pathname, download.filename), Cloud.optionsLogMessage('WARN'));
|
|
717
738
|
throw err;
|
|
718
739
|
}
|
|
719
|
-
return new Promise((resolve, reject) => {
|
|
720
|
-
handler({ bucket, download }, async (err, value) => {
|
|
721
|
-
if (err) {
|
|
722
|
-
reject(errorObject(err, service, "Download failed"));
|
|
723
|
-
}
|
|
724
|
-
else if (value) {
|
|
725
|
-
if (beforeResolve) {
|
|
726
|
-
const output = await beforeResolve(value);
|
|
727
|
-
if ((0, types_1.isString)(output)) {
|
|
728
|
-
value = output;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
if (typeof value === 'string' && path.isAbsolute(value)) {
|
|
732
|
-
this.addLog(4, 'downloadObject: ' + bucket, service, value);
|
|
733
|
-
this.downloaded.push(value);
|
|
734
|
-
}
|
|
735
|
-
resolve(value);
|
|
736
|
-
}
|
|
737
|
-
else {
|
|
738
|
-
reject((0, types_1.errorMessage)(service, "Download failed"));
|
|
739
|
-
}
|
|
740
|
-
});
|
|
741
|
-
});
|
|
742
740
|
}
|
|
743
741
|
async getDatabaseRows(item, ignoreErrors, sessionKey) {
|
|
744
742
|
if (this.aborted) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/cloud",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.2",
|
|
4
4
|
"description": "Cloud constructor for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"license": "BSD-3-Clause",
|
|
20
20
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@e-mc/core": "0.13.
|
|
23
|
-
"@e-mc/db": "0.13.
|
|
24
|
-
"@e-mc/types": "0.13.
|
|
22
|
+
"@e-mc/core": "0.13.2",
|
|
23
|
+
"@e-mc/db": "0.13.2",
|
|
24
|
+
"@e-mc/types": "0.13.2",
|
|
25
25
|
"mime-types": "^3.0.1"
|
|
26
26
|
}
|
|
27
27
|
}
|