@naturalcycles/cloud-storage-lib 1.13.1 → 1.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/dist/cloudStorage.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { CommonLogger, LocalTimeInput } from '@naturalcycles/js-lib';
|
|
|
3
3
|
import type { ReadableBinary, ReadableTyped, WritableBinary } from '@naturalcycles/nodejs-lib';
|
|
4
4
|
import type { CommonStorage, CommonStorageGetOptions, FileEntry } from './commonStorage';
|
|
5
5
|
import type { GCPServiceAccount } from './model';
|
|
6
|
-
export {
|
|
6
|
+
export type { Storage, StorageOptions, };
|
|
7
7
|
/**
|
|
8
8
|
* This object is intentionally made to NOT extend StorageOptions,
|
|
9
9
|
* because StorageOptions is complicated and provides just too many ways
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CommonDBCreateOptions, CommonKeyValueDB, KeyValueDBTuple } from '@naturalcycles/db-lib';
|
|
2
|
+
import { StringMap } from '@naturalcycles/js-lib';
|
|
2
3
|
import { ReadableTyped } from '@naturalcycles/nodejs-lib';
|
|
3
4
|
import { CommonStorage } from './commonStorage';
|
|
4
5
|
export interface CommonStorageKeyValueDBCfg {
|
|
@@ -16,6 +17,10 @@ export interface CommonStorageKeyValueDBCfg {
|
|
|
16
17
|
export declare class CommonStorageKeyValueDB implements CommonKeyValueDB {
|
|
17
18
|
cfg: CommonStorageKeyValueDBCfg;
|
|
18
19
|
constructor(cfg: CommonStorageKeyValueDBCfg);
|
|
20
|
+
support: {
|
|
21
|
+
increment: boolean;
|
|
22
|
+
count?: boolean;
|
|
23
|
+
};
|
|
19
24
|
ping(): Promise<void>;
|
|
20
25
|
createTable(_table: string, _opt?: CommonDBCreateOptions): Promise<void>;
|
|
21
26
|
/**
|
|
@@ -30,4 +35,5 @@ export declare class CommonStorageKeyValueDB implements CommonKeyValueDB {
|
|
|
30
35
|
streamEntries(table: string, limit?: number): ReadableTyped<KeyValueDBTuple>;
|
|
31
36
|
count(table: string): Promise<number>;
|
|
32
37
|
increment(_table: string, _id: string, _by?: number): Promise<number>;
|
|
38
|
+
incrementBatch(_table: string, _incrementMap: StringMap<number>): Promise<StringMap<number>>;
|
|
33
39
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommonStorageKeyValueDB = void 0;
|
|
4
|
+
const db_lib_1 = require("@naturalcycles/db-lib");
|
|
4
5
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
6
|
/**
|
|
6
7
|
* CommonKeyValueDB, backed up by a CommonStorage implementation.
|
|
@@ -13,6 +14,10 @@ const js_lib_1 = require("@naturalcycles/js-lib");
|
|
|
13
14
|
class CommonStorageKeyValueDB {
|
|
14
15
|
constructor(cfg) {
|
|
15
16
|
this.cfg = cfg;
|
|
17
|
+
this.support = {
|
|
18
|
+
...db_lib_1.commonKeyValueDBFullSupport,
|
|
19
|
+
increment: false,
|
|
20
|
+
};
|
|
16
21
|
}
|
|
17
22
|
async ping() {
|
|
18
23
|
await this.cfg.storage.ping(this.cfg.bucketName);
|
|
@@ -80,5 +85,8 @@ class CommonStorageKeyValueDB {
|
|
|
80
85
|
async increment(_table, _id, _by) {
|
|
81
86
|
throw new js_lib_1.AppError('CommonStorageKeyValueDB.increment() is not implemented');
|
|
82
87
|
}
|
|
88
|
+
async incrementBatch(_table, _incrementMap) {
|
|
89
|
+
throw new js_lib_1.AppError('CommonStorageKeyValueDB.incrementBatch() is not implemented');
|
|
90
|
+
}
|
|
83
91
|
}
|
|
84
92
|
exports.CommonStorageKeyValueDB = CommonStorageKeyValueDB;
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/cloud-storage-lib",
|
|
3
3
|
"scripts": {
|
|
4
|
-
"prepare": "husky"
|
|
4
|
+
"prepare": "husky",
|
|
5
|
+
"build": "dev-lib build",
|
|
6
|
+
"test": "dev-lib test",
|
|
7
|
+
"lint": "dev-lib lint",
|
|
8
|
+
"bt": "dev-lib bt",
|
|
9
|
+
"lbt": "dev-lib lbt"
|
|
5
10
|
},
|
|
6
11
|
"dependencies": {
|
|
7
12
|
"@google-cloud/storage": "^7.0.0",
|
|
@@ -11,7 +16,7 @@
|
|
|
11
16
|
},
|
|
12
17
|
"devDependencies": {
|
|
13
18
|
"@naturalcycles/dev-lib": "^15.18.0",
|
|
14
|
-
"@types/node": "^
|
|
19
|
+
"@types/node": "^22.7.4",
|
|
15
20
|
"firebase-admin": "^12.0.0",
|
|
16
21
|
"jest": "^29.1.2"
|
|
17
22
|
},
|
|
@@ -33,9 +38,9 @@
|
|
|
33
38
|
"url": "https://github.com/NaturalCycles/cloud-storage-lib"
|
|
34
39
|
},
|
|
35
40
|
"engines": {
|
|
36
|
-
"node": ">=
|
|
41
|
+
"node": ">=20.13.0"
|
|
37
42
|
},
|
|
38
|
-
"version": "1.13.
|
|
43
|
+
"version": "1.13.2",
|
|
39
44
|
"description": "CommonStorage implementation based on Google Cloud Storage",
|
|
40
45
|
"author": "Natural Cycles Team",
|
|
41
46
|
"license": "MIT"
|
package/src/cloudStorage.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// eslint-disable-next-line import/no-duplicates
|
|
1
|
+
// eslint-disable-next-line import-x/no-duplicates
|
|
2
2
|
import type { File, Storage, StorageOptions } from '@google-cloud/storage'
|
|
3
|
-
// eslint-disable-next-line import/no-duplicates
|
|
3
|
+
// eslint-disable-next-line import-x/no-duplicates
|
|
4
4
|
import type * as StorageLib from '@google-cloud/storage'
|
|
5
5
|
import {
|
|
6
6
|
_assert,
|
|
@@ -17,10 +17,10 @@ import type { ReadableBinary, ReadableTyped, WritableBinary } from '@naturalcycl
|
|
|
17
17
|
import type { CommonStorage, CommonStorageGetOptions, FileEntry } from './commonStorage'
|
|
18
18
|
import type { GCPServiceAccount } from './model'
|
|
19
19
|
|
|
20
|
-
export {
|
|
20
|
+
export type {
|
|
21
21
|
// This is the latest version, to be imported by consumers
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
Storage,
|
|
23
|
+
StorageOptions,
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const MAX_RECURSION_DEPTH = 10
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CommonDBCreateOptions,
|
|
3
|
+
CommonKeyValueDB,
|
|
4
|
+
commonKeyValueDBFullSupport,
|
|
5
|
+
KeyValueDBTuple,
|
|
6
|
+
} from '@naturalcycles/db-lib'
|
|
2
7
|
import { AppError, pMap, StringMap } from '@naturalcycles/js-lib'
|
|
3
8
|
import { ReadableTyped } from '@naturalcycles/nodejs-lib'
|
|
4
9
|
import { CommonStorage } from './commonStorage'
|
|
@@ -19,6 +24,11 @@ export interface CommonStorageKeyValueDBCfg {
|
|
|
19
24
|
export class CommonStorageKeyValueDB implements CommonKeyValueDB {
|
|
20
25
|
constructor(public cfg: CommonStorageKeyValueDBCfg) {}
|
|
21
26
|
|
|
27
|
+
support = {
|
|
28
|
+
...commonKeyValueDBFullSupport,
|
|
29
|
+
increment: false,
|
|
30
|
+
}
|
|
31
|
+
|
|
22
32
|
async ping(): Promise<void> {
|
|
23
33
|
await this.cfg.storage.ping(this.cfg.bucketName)
|
|
24
34
|
}
|
|
@@ -104,4 +114,11 @@ export class CommonStorageKeyValueDB implements CommonKeyValueDB {
|
|
|
104
114
|
async increment(_table: string, _id: string, _by?: number): Promise<number> {
|
|
105
115
|
throw new AppError('CommonStorageKeyValueDB.increment() is not implemented')
|
|
106
116
|
}
|
|
117
|
+
|
|
118
|
+
async incrementBatch(
|
|
119
|
+
_table: string,
|
|
120
|
+
_incrementMap: StringMap<number>,
|
|
121
|
+
): Promise<StringMap<number>> {
|
|
122
|
+
throw new AppError('CommonStorageKeyValueDB.incrementBatch() is not implemented')
|
|
123
|
+
}
|
|
107
124
|
}
|