@naturalcycles/cloud-storage-lib 2.4.0 → 2.5.0
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.
|
@@ -17,10 +17,7 @@ export interface CommonStorageKeyValueDBCfg {
|
|
|
17
17
|
export declare class CommonStorageKeyValueDB implements CommonKeyValueDB {
|
|
18
18
|
cfg: CommonStorageKeyValueDBCfg;
|
|
19
19
|
constructor(cfg: CommonStorageKeyValueDBCfg);
|
|
20
|
-
support:
|
|
21
|
-
increment: boolean;
|
|
22
|
-
count?: boolean;
|
|
23
|
-
};
|
|
20
|
+
support: any;
|
|
24
21
|
ping(): Promise<void>;
|
|
25
22
|
createTable(_table: string, _opt?: CommonDBCreateOptions): Promise<void>;
|
|
26
23
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LocalTimeInput } from '@naturalcycles/js-lib/datetime';
|
|
2
2
|
import type { StringMap } from '@naturalcycles/js-lib/types';
|
|
3
|
-
import {
|
|
3
|
+
import type { ReadableBinary, ReadableTyped, WritableBinary } from '@naturalcycles/nodejs-lib/stream';
|
|
4
4
|
import type { CommonStorage, CommonStorageGetOptions, FileEntry } from './commonStorage.js';
|
|
5
5
|
export declare class InMemoryCommonStorage implements CommonStorage {
|
|
6
6
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
1
2
|
import { _isTruthy } from '@naturalcycles/js-lib';
|
|
2
3
|
import { localTime } from '@naturalcycles/js-lib/datetime/localTime.js';
|
|
3
4
|
import { _assert } from '@naturalcycles/js-lib/error/assert.js';
|
|
@@ -5,7 +6,6 @@ import { _substringAfterLast } from '@naturalcycles/js-lib/string';
|
|
|
5
6
|
import { _stringMapEntries } from '@naturalcycles/js-lib/types';
|
|
6
7
|
import { md5 } from '@naturalcycles/nodejs-lib';
|
|
7
8
|
import { fs2 } from '@naturalcycles/nodejs-lib/fs2';
|
|
8
|
-
import { readableFrom, } from '@naturalcycles/nodejs-lib/stream';
|
|
9
9
|
export class InMemoryCommonStorage {
|
|
10
10
|
/**
|
|
11
11
|
* data[bucketName][filePath] = Buffer
|
|
@@ -17,7 +17,7 @@ export class InMemoryCommonStorage {
|
|
|
17
17
|
return Object.keys(this.data);
|
|
18
18
|
}
|
|
19
19
|
getBucketNamesStream() {
|
|
20
|
-
return
|
|
20
|
+
return Readable.from(Object.keys(this.data));
|
|
21
21
|
}
|
|
22
22
|
async fileExists(bucketName, filePath) {
|
|
23
23
|
return !!this.data[bucketName]?.[filePath];
|
|
@@ -52,14 +52,14 @@ export class InMemoryCommonStorage {
|
|
|
52
52
|
}
|
|
53
53
|
getFileNamesStream(bucketName, opt = {}) {
|
|
54
54
|
const { prefix = '', fullPaths = true } = opt;
|
|
55
|
-
return
|
|
55
|
+
return Readable.from(Object.keys(this.data[bucketName] || {})
|
|
56
56
|
.filter(filePath => filePath.startsWith(prefix))
|
|
57
57
|
.slice(0, opt.limit)
|
|
58
58
|
.map(n => (fullPaths ? n : _substringAfterLast(n, '/'))));
|
|
59
59
|
}
|
|
60
60
|
getFilesStream(bucketName, opt = {}) {
|
|
61
61
|
const { prefix = '', fullPaths = true } = opt;
|
|
62
|
-
return
|
|
62
|
+
return Readable.from(_stringMapEntries(this.data[bucketName] || {})
|
|
63
63
|
.map(([filePath, content]) => ({
|
|
64
64
|
filePath,
|
|
65
65
|
content,
|
|
@@ -69,7 +69,7 @@ export class InMemoryCommonStorage {
|
|
|
69
69
|
.map(f => (fullPaths ? f : { ...f, filePath: _substringAfterLast(f.filePath, '/') })));
|
|
70
70
|
}
|
|
71
71
|
getFileReadStream(bucketName, filePath) {
|
|
72
|
-
return
|
|
72
|
+
return Readable.from(this.data[bucketName][filePath]);
|
|
73
73
|
}
|
|
74
74
|
getFileWriteStream(_bucketName, _filePath) {
|
|
75
75
|
throw new Error('Method not implemented.');
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@types/node": "^24",
|
|
13
13
|
"firebase-admin": "^13",
|
|
14
|
-
"@naturalcycles/dev-lib": "
|
|
14
|
+
"@naturalcycles/dev-lib": "18.4.2"
|
|
15
15
|
},
|
|
16
16
|
"exports": {
|
|
17
17
|
".": "./dist/index.js"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=22.12.0"
|
|
39
39
|
},
|
|
40
|
-
"version": "2.
|
|
40
|
+
"version": "2.5.0",
|
|
41
41
|
"description": "CommonStorage implementation based on Google Cloud Storage",
|
|
42
42
|
"author": "Natural Cycles Team",
|
|
43
43
|
"license": "MIT",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Readable } from 'node:stream'
|
|
1
2
|
import { _isTruthy } from '@naturalcycles/js-lib'
|
|
2
3
|
import type { LocalTimeInput } from '@naturalcycles/js-lib/datetime'
|
|
3
4
|
import { localTime } from '@naturalcycles/js-lib/datetime/localTime.js'
|
|
@@ -7,11 +8,10 @@ import type { StringMap } from '@naturalcycles/js-lib/types'
|
|
|
7
8
|
import { _stringMapEntries } from '@naturalcycles/js-lib/types'
|
|
8
9
|
import { md5 } from '@naturalcycles/nodejs-lib'
|
|
9
10
|
import { fs2 } from '@naturalcycles/nodejs-lib/fs2'
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
type WritableBinary,
|
|
11
|
+
import type {
|
|
12
|
+
ReadableBinary,
|
|
13
|
+
ReadableTyped,
|
|
14
|
+
WritableBinary,
|
|
15
15
|
} from '@naturalcycles/nodejs-lib/stream'
|
|
16
16
|
import type { CommonStorage, CommonStorageGetOptions, FileEntry } from './commonStorage.js'
|
|
17
17
|
|
|
@@ -30,7 +30,7 @@ export class InMemoryCommonStorage implements CommonStorage {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
getBucketNamesStream(): ReadableTyped<string> {
|
|
33
|
-
return
|
|
33
|
+
return Readable.from(Object.keys(this.data))
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
async fileExists(bucketName: string, filePath: string): Promise<boolean> {
|
|
@@ -73,7 +73,7 @@ export class InMemoryCommonStorage implements CommonStorage {
|
|
|
73
73
|
getFileNamesStream(bucketName: string, opt: CommonStorageGetOptions = {}): ReadableTyped<string> {
|
|
74
74
|
const { prefix = '', fullPaths = true } = opt
|
|
75
75
|
|
|
76
|
-
return
|
|
76
|
+
return Readable.from(
|
|
77
77
|
Object.keys(this.data[bucketName] || {})
|
|
78
78
|
.filter(filePath => filePath.startsWith(prefix))
|
|
79
79
|
.slice(0, opt.limit)
|
|
@@ -84,7 +84,7 @@ export class InMemoryCommonStorage implements CommonStorage {
|
|
|
84
84
|
getFilesStream(bucketName: string, opt: CommonStorageGetOptions = {}): ReadableTyped<FileEntry> {
|
|
85
85
|
const { prefix = '', fullPaths = true } = opt
|
|
86
86
|
|
|
87
|
-
return
|
|
87
|
+
return Readable.from(
|
|
88
88
|
_stringMapEntries(this.data[bucketName] || {})
|
|
89
89
|
.map(([filePath, content]) => ({
|
|
90
90
|
filePath,
|
|
@@ -97,7 +97,7 @@ export class InMemoryCommonStorage implements CommonStorage {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
getFileReadStream(bucketName: string, filePath: string): ReadableBinary {
|
|
100
|
-
return
|
|
100
|
+
return Readable.from(this.data[bucketName]![filePath]!)
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
getFileWriteStream(_bucketName: string, _filePath: string): WritableBinary {
|