@naturalcycles/cloud-storage-lib 1.12.0 → 1.12.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/dist/cloudStorage.d.ts +0 -1
- package/dist/cloudStorage.js +1 -1
- package/dist/commonStorage.d.ts +0 -1
- package/dist/commonStorageBucket.d.ts +0 -2
- package/dist/commonStorageKeyValueDB.d.ts +0 -1
- package/dist/inMemoryCommonStorage.d.ts +0 -1
- package/dist/inMemoryCommonStorage.js +1 -1
- package/dist/testing/commonStorageTest.js +1 -2
- package/package.json +1 -1
- package/src/cloudStorage.ts +1 -1
- package/src/inMemoryCommonStorage.ts +9 -9
package/dist/cloudStorage.d.ts
CHANGED
package/dist/cloudStorage.js
CHANGED
package/dist/commonStorage.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { LocalTimeInput, StringMap } from '@naturalcycles/js-lib';
|
|
3
2
|
import { ReadableBinary, ReadableTyped, WritableBinary } from '@naturalcycles/nodejs-lib';
|
|
4
3
|
import { CommonStorage, CommonStorageGetOptions, FileEntry } from './commonStorage';
|
|
@@ -125,7 +125,7 @@ class InMemoryCommonStorage {
|
|
|
125
125
|
const buf = this.data[bucketName]?.[filePath];
|
|
126
126
|
(0, js_lib_1._assert)(buf, `getSignedUrl file not found: ${bucketName}/${filePath}`);
|
|
127
127
|
const signature = (0, nodejs_lib_1.md5)(buf);
|
|
128
|
-
return `https://testurl.com/${bucketName}/${filePath}?expires=${(0, js_lib_1.localTime)(expires).unix
|
|
128
|
+
return `https://testurl.com/${bucketName}/${filePath}?expires=${(0, js_lib_1.localTime)(expires).unix}&signature=${signature}`;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
exports.InMemoryCommonStorage = InMemoryCommonStorage;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runCommonStorageTest =
|
|
3
|
+
exports.runCommonStorageTest = runCommonStorageTest;
|
|
4
4
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
5
|
const TEST_FOLDER = 'test/subdir';
|
|
6
6
|
const TEST_ITEMS = (0, js_lib_1._range)(10).map(n => ({
|
|
@@ -114,4 +114,3 @@ function runCommonStorageTest(storage, bucketName) {
|
|
|
114
114
|
})
|
|
115
115
|
*/
|
|
116
116
|
}
|
|
117
|
-
exports.runCommonStorageTest = runCommonStorageTest;
|
package/package.json
CHANGED
package/src/cloudStorage.ts
CHANGED
|
@@ -45,7 +45,7 @@ export class InMemoryCommonStorage implements CommonStorage {
|
|
|
45
45
|
|
|
46
46
|
async saveFile(bucketName: string, filePath: string, content: Buffer): Promise<void> {
|
|
47
47
|
this.data[bucketName] ||= {}
|
|
48
|
-
this.data[bucketName]
|
|
48
|
+
this.data[bucketName][filePath] = content
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
async deletePath(bucketName: string, prefix: string): Promise<void> {
|
|
@@ -112,12 +112,12 @@ export class InMemoryCommonStorage implements CommonStorage {
|
|
|
112
112
|
bucketFilePath: string,
|
|
113
113
|
): Promise<void> {
|
|
114
114
|
this.data[bucketName] ||= {}
|
|
115
|
-
this.data[bucketName]
|
|
115
|
+
this.data[bucketName][bucketFilePath] = await fs2.readBufferAsync(localFilePath)
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
async setFileVisibility(bucketName: string, filePath: string, isPublic: boolean): Promise<void> {
|
|
119
119
|
this.publicMap[bucketName] ||= {}
|
|
120
|
-
this.publicMap[bucketName]
|
|
120
|
+
this.publicMap[bucketName][filePath] = isPublic
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
async getFileVisibility(bucketName: string, filePath: string): Promise<boolean> {
|
|
@@ -133,7 +133,7 @@ export class InMemoryCommonStorage implements CommonStorage {
|
|
|
133
133
|
const tob = toBucket || fromBucket
|
|
134
134
|
this.data[fromBucket] ||= {}
|
|
135
135
|
this.data[tob] ||= {}
|
|
136
|
-
this.data[tob]
|
|
136
|
+
this.data[tob][toPath] = this.data[fromBucket][fromPath]
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
async moveFile(
|
|
@@ -145,8 +145,8 @@ export class InMemoryCommonStorage implements CommonStorage {
|
|
|
145
145
|
const tob = toBucket || fromBucket
|
|
146
146
|
this.data[fromBucket] ||= {}
|
|
147
147
|
this.data[tob] ||= {}
|
|
148
|
-
this.data[tob]
|
|
149
|
-
delete this.data[fromBucket]
|
|
148
|
+
this.data[tob][toPath] = this.data[fromBucket][fromPath]
|
|
149
|
+
delete this.data[fromBucket][fromPath]
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
async movePath(
|
|
@@ -159,7 +159,7 @@ export class InMemoryCommonStorage implements CommonStorage {
|
|
|
159
159
|
this.data[fromBucket] ||= {}
|
|
160
160
|
this.data[tob] ||= {}
|
|
161
161
|
|
|
162
|
-
_stringMapEntries(this.data[fromBucket]
|
|
162
|
+
_stringMapEntries(this.data[fromBucket]).forEach(([filePath, v]) => {
|
|
163
163
|
if (!filePath.startsWith(fromPrefix)) return
|
|
164
164
|
this.data[tob]![toPrefix + filePath.slice(fromPrefix.length)] = v
|
|
165
165
|
delete this.data[fromBucket]![filePath]
|
|
@@ -185,7 +185,7 @@ export class InMemoryCommonStorage implements CommonStorage {
|
|
|
185
185
|
if (!this.data[bucketName]) return
|
|
186
186
|
const tob = toBucket || bucketName
|
|
187
187
|
this.data[tob] ||= {}
|
|
188
|
-
this.data[tob]
|
|
188
|
+
this.data[tob][toPath] = Buffer.concat(
|
|
189
189
|
filePaths.map(p => this.data[bucketName]![p]).filter(_isTruthy),
|
|
190
190
|
)
|
|
191
191
|
|
|
@@ -201,6 +201,6 @@ export class InMemoryCommonStorage implements CommonStorage {
|
|
|
201
201
|
const buf = this.data[bucketName]?.[filePath]
|
|
202
202
|
_assert(buf, `getSignedUrl file not found: ${bucketName}/${filePath}`)
|
|
203
203
|
const signature = md5(buf)
|
|
204
|
-
return `https://testurl.com/${bucketName}/${filePath}?expires=${localTime(expires).unix
|
|
204
|
+
return `https://testurl.com/${bucketName}/${filePath}?expires=${localTime(expires).unix}&signature=${signature}`
|
|
205
205
|
}
|
|
206
206
|
}
|