@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.
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { Storage, StorageOptions } from '@google-cloud/storage';
3
2
  import { CommonLogger, LocalTimeInput } from '@naturalcycles/js-lib';
4
3
  import type { ReadableBinary, ReadableTyped, WritableBinary } from '@naturalcycles/nodejs-lib';
@@ -227,7 +227,7 @@ class CloudStorage {
227
227
  .getSignedUrl({
228
228
  action: 'read',
229
229
  version: 'v4',
230
- expires: (0, js_lib_1.localTime)(expires).unixMillis(),
230
+ expires: (0, js_lib_1.localTime)(expires).unixMillis,
231
231
  });
232
232
  return url;
233
233
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { LocalTimeInput } from '@naturalcycles/js-lib';
3
2
  import type { ReadableBinary, ReadableTyped, WritableBinary } from '@naturalcycles/nodejs-lib';
4
3
  export interface FileEntry {
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { Readable, Writable } from 'node:stream';
4
2
  import { ReadableTyped } from '@naturalcycles/nodejs-lib';
5
3
  import { CommonStorage, CommonStorageGetOptions, FileEntry } from './commonStorage';
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { CommonDBCreateOptions, CommonKeyValueDB, KeyValueDBTuple } from '@naturalcycles/db-lib';
3
2
  import { ReadableTyped } from '@naturalcycles/nodejs-lib';
4
3
  import { CommonStorage } from './commonStorage';
@@ -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()}&signature=${signature}`;
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 = void 0;
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
@@ -35,7 +35,7 @@
35
35
  "engines": {
36
36
  "node": ">=18.12.0"
37
37
  },
38
- "version": "1.12.0",
38
+ "version": "1.12.1",
39
39
  "description": "CommonStorage implementation based on Google Cloud Storage",
40
40
  "author": "Natural Cycles Team",
41
41
  "license": "MIT"
@@ -374,7 +374,7 @@ export class CloudStorage implements CommonStorage {
374
374
  .getSignedUrl({
375
375
  action: 'read',
376
376
  version: 'v4',
377
- expires: localTime(expires).unixMillis(),
377
+ expires: localTime(expires).unixMillis,
378
378
  })
379
379
 
380
380
  return url
@@ -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]![filePath] = content
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]![bucketFilePath] = await fs2.readBufferAsync(localFilePath)
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]![filePath] = isPublic
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]![toPath] = this.data[fromBucket]![fromPath]
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]![toPath] = this.data[fromBucket]![fromPath]
149
- delete this.data[fromBucket]![fromPath]
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]!).forEach(([filePath, v]) => {
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]![toPath] = Buffer.concat(
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()}&signature=${signature}`
204
+ return `https://testurl.com/${bucketName}/${filePath}?expires=${localTime(expires).unix}&signature=${signature}`
205
205
  }
206
206
  }