@e-mc/cloud 0.13.9 → 0.13.10
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 +21 -23
- package/package.json +4 -4
- package/util.d.ts +12 -1
- package/util.js +22 -16
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.10/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { IFileManager, 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.10/lib/asset.d.ts
|
|
184
|
+
- https://www.unpkg.com/@e-mc/types@0.13.10/lib/cloud.d.ts
|
|
185
|
+
- https://www.unpkg.com/@e-mc/types@0.13.10/lib/core.d.ts
|
|
186
|
+
- https://www.unpkg.com/@e-mc/types@0.13.10/lib/db.d.ts
|
|
187
|
+
- https://www.unpkg.com/@e-mc/types@0.13.10/lib/logger.d.ts
|
|
188
|
+
- https://www.unpkg.com/@e-mc/types@0.13.10/lib/settings.d.ts
|
|
189
189
|
|
|
190
190
|
## LICENSE
|
|
191
191
|
|
package/index.js
CHANGED
|
@@ -505,34 +505,32 @@ class Cloud extends core_1.ClientDb {
|
|
|
505
505
|
const current = storage[i];
|
|
506
506
|
for (const data of current.cloudStorage) {
|
|
507
507
|
const trailing = data.upload;
|
|
508
|
-
if (
|
|
509
|
-
continue;
|
|
510
|
-
}
|
|
511
|
-
renamed: {
|
|
508
|
+
if (trailing) {
|
|
512
509
|
const basename = trailing.filename;
|
|
513
510
|
const filename = basename || current.filename;
|
|
514
511
|
const trailingFolder = trailing.pathname || '';
|
|
515
512
|
const trailingName = this.joinPath(trailingFolder, filename);
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
513
|
+
renamed: {
|
|
514
|
+
for (let j = 0; j < length - 1; ++j) {
|
|
515
|
+
const previous = storage[j];
|
|
516
|
+
if (current !== previous) {
|
|
517
|
+
for (const other of previous.cloudStorage) {
|
|
518
|
+
const leading = other.upload;
|
|
519
|
+
if (leading && hasSameBucket(data, other)) {
|
|
520
|
+
const leadingFolder = leading.pathname || '';
|
|
521
|
+
if (basename && basename === leading.filename && leadingFolder === trailingFolder) {
|
|
522
|
+
renameTrailing(nameIndex, trailing, trailingFolder, basename);
|
|
523
|
+
break renamed;
|
|
524
|
+
}
|
|
525
|
+
const leadingName = this.joinPath(leadingFolder, leading.filename || previous.filename);
|
|
526
|
+
if (trailingName === leadingName) {
|
|
527
|
+
if (!trailing.overwrite || leading.overwrite) {
|
|
528
|
+
renameTrailing(nameIndex, trailing, trailingFolder, filename);
|
|
529
|
+
break renamed;
|
|
530
|
+
}
|
|
531
|
+
leading.filename = assignFilename(leading.filename || previous.filename);
|
|
532
|
+
}
|
|
534
533
|
}
|
|
535
|
-
leading.filename = assignFilename(leading.filename || previous.filename);
|
|
536
534
|
}
|
|
537
535
|
}
|
|
538
536
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/cloud",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.10",
|
|
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.10",
|
|
23
|
+
"@e-mc/db": "0.13.10",
|
|
24
|
+
"@e-mc/types": "0.13.10",
|
|
25
25
|
"mime-types": "^3.0.2"
|
|
26
26
|
}
|
|
27
27
|
}
|
package/util.d.ts
CHANGED
|
@@ -5,8 +5,19 @@ import type { AuthValue } from '@e-mc/types/lib/http';
|
|
|
5
5
|
import type { Readable } from 'node:stream';
|
|
6
6
|
|
|
7
7
|
declare namespace util {
|
|
8
|
+
interface CreateKeyAndBodyOptions {
|
|
9
|
+
errorCallback?: FunctionType<void>;
|
|
10
|
+
descendantsGroup?: string[];
|
|
11
|
+
flags?: number;
|
|
12
|
+
chunkSize?: number;
|
|
13
|
+
mimeType?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
function readableAsBuffer(from: Readable): Promise<Buffer | null>;
|
|
9
|
-
function createKeyAndBody<T = Buffer>(filename: string, items: UploadContent[],
|
|
17
|
+
function createKeyAndBody<T = Buffer>(filename: string, items: UploadContent[], options: CreateKeyAndBodyOptions): [string[], T[], string[]];
|
|
18
|
+
function createKeyAndBody<T = Buffer>(filename: string, items: UploadContent[], errorCallback: FunctionType<void>, flags?: number): [string[], T[], string[]];
|
|
19
|
+
/** @deprecated options */
|
|
20
|
+
function createKeyAndBody<T = Buffer>(filename: string, items: UploadContent[], chunkSize?: number | string | FunctionType<void>, errorCallback?: FunctionType<void> | number, flags?: number, descendantsGroup?: string[]): [string[], T[], string[]];
|
|
10
21
|
function createErrorHandler(instance: IModule, service: string, bucket: string): (err: unknown) => void;
|
|
11
22
|
function generateFilename(filename: string): (i: number) => [string, boolean];
|
|
12
23
|
function getBasicAuth(auth: AuthValue): string;
|
package/util.js
CHANGED
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "hasBasicAuth", { enumerable: true, get: function
|
|
|
17
17
|
async function readableAsBuffer(from) {
|
|
18
18
|
return new Promise((resolve, reject) => {
|
|
19
19
|
let result = null;
|
|
20
|
-
from.on('data', chunk => {
|
|
20
|
+
from.on('data', (chunk) => {
|
|
21
21
|
if (!Buffer.isBuffer(chunk)) {
|
|
22
22
|
chunk = Buffer.from(chunk);
|
|
23
23
|
}
|
|
@@ -30,21 +30,26 @@ async function readableAsBuffer(from) {
|
|
|
30
30
|
.read();
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
function createKeyAndBody(filename, items, chunkSize = 0, errorCallback, flags = 0) {
|
|
33
|
+
function createKeyAndBody(filename, items, chunkSize = 0, errorCallback, flags = 0, descendantsGroup = ['.map']) {
|
|
34
34
|
let mimeType;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
errorCallback = chunkSize;
|
|
38
|
-
chunkSize = 0;
|
|
39
|
-
break;
|
|
40
|
-
case 'string':
|
|
41
|
-
mimeType = chunkSize;
|
|
42
|
-
chunkSize = 0;
|
|
43
|
-
break;
|
|
35
|
+
if ((0, types_1.isPlainObject)(chunkSize)) {
|
|
36
|
+
({ errorCallback, mimeType, chunkSize = 0, flags = 0, descendantsGroup } = chunkSize);
|
|
44
37
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
else {
|
|
39
|
+
switch (typeof chunkSize) {
|
|
40
|
+
case 'function':
|
|
41
|
+
errorCallback = chunkSize;
|
|
42
|
+
chunkSize = 0;
|
|
43
|
+
break;
|
|
44
|
+
case 'string':
|
|
45
|
+
mimeType = chunkSize;
|
|
46
|
+
chunkSize = 0;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
if (typeof errorCallback === 'number') {
|
|
50
|
+
flags = errorCallback;
|
|
51
|
+
errorCallback = undefined;
|
|
52
|
+
}
|
|
48
53
|
}
|
|
49
54
|
const key = [];
|
|
50
55
|
const body = [];
|
|
@@ -105,9 +110,10 @@ function createKeyAndBody(filename, items, chunkSize = 0, errorCallback, flags =
|
|
|
105
110
|
}
|
|
106
111
|
if (target) {
|
|
107
112
|
const output = filename + ext;
|
|
108
|
-
|
|
113
|
+
const descendant = Array.isArray(descendantsGroup) && descendantsGroup.includes(ext);
|
|
114
|
+
key.push(descendant && localFile ? path.basename(localFile) : output);
|
|
109
115
|
body.push(target);
|
|
110
|
-
type.push(
|
|
116
|
+
type.push(!descendant && mime.lookup(output) || mimeType || "application/octet-stream");
|
|
111
117
|
}
|
|
112
118
|
}
|
|
113
119
|
catch (err) {
|