proto.io 0.0.208 → 0.0.209
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/adapters/file/aliyun-oss.d.ts +6 -6
- package/dist/adapters/file/aliyun-oss.js +14 -13
- package/dist/adapters/file/aliyun-oss.js.map +1 -1
- package/dist/adapters/file/aliyun-oss.mjs +14 -13
- package/dist/adapters/file/aliyun-oss.mjs.map +1 -1
- package/dist/adapters/file/database.d.ts +3 -3
- package/dist/adapters/file/database.js +2 -2
- package/dist/adapters/file/database.js.map +1 -1
- package/dist/adapters/file/database.mjs +2 -2
- package/dist/adapters/file/database.mjs.map +1 -1
- package/dist/adapters/file/filesystem.d.ts +5 -5
- package/dist/adapters/file/filesystem.js +11 -7
- package/dist/adapters/file/filesystem.js.map +1 -1
- package/dist/adapters/file/filesystem.mjs +11 -7
- package/dist/adapters/file/filesystem.mjs.map +1 -1
- package/dist/adapters/file/google-cloud-storage.d.ts +6 -6
- package/dist/adapters/file/google-cloud-storage.js +23 -13
- package/dist/adapters/file/google-cloud-storage.js.map +1 -1
- package/dist/adapters/file/google-cloud-storage.mjs +23 -13
- package/dist/adapters/file/google-cloud-storage.mjs.map +1 -1
- package/dist/adapters/storage/progres.d.ts +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js +1 -1
- package/dist/client.mjs +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +25 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -10
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{base-CfQi0T0I.mjs → base-DYc1_peK.mjs} +3 -3
- package/dist/internals/{base-CfQi0T0I.mjs.map → base-DYc1_peK.mjs.map} +1 -1
- package/dist/internals/{base-wSknxBv7.d.ts → base-DbSaGX_u.d.ts} +2 -2
- package/dist/internals/base-DbSaGX_u.d.ts.map +1 -0
- package/dist/internals/{base-BFKQpiws.js → base-NsJYo2MG.js} +3 -3
- package/dist/internals/{base-BFKQpiws.js.map → base-NsJYo2MG.js.map} +1 -1
- package/dist/internals/{chunk-BuMQw4dz.js → chunk-BuKmyceG.js} +5 -3
- package/dist/internals/chunk-BuKmyceG.js.map +1 -0
- package/dist/internals/{chunk-C_BXf1Er.d.ts → chunk-bYrnqXiI.d.ts} +6 -6
- package/dist/internals/chunk-bYrnqXiI.d.ts.map +1 -0
- package/dist/internals/{chunk-DxYhYVky.mjs → chunk-bpt1C6W4.mjs} +5 -3
- package/dist/internals/chunk-bpt1C6W4.mjs.map +1 -0
- package/dist/internals/{index-DVUiXLfI.js → index-CK1snZyh.js} +3 -1
- package/dist/internals/index-CK1snZyh.js.map +1 -0
- package/dist/internals/{index-A-hoMfDO.d.ts → index-Dn1IkLDx.d.ts} +14 -1
- package/dist/internals/index-Dn1IkLDx.d.ts.map +1 -0
- package/dist/internals/{index-iqOd-Wdg.d.ts → index-Dx36qTUa.d.ts} +2 -2
- package/dist/internals/index-Dx36qTUa.d.ts.map +1 -0
- package/dist/internals/{index-BvwYz4Yp.mjs → index-Eo70ZAdZ.mjs} +3 -2
- package/dist/internals/index-Eo70ZAdZ.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/internals/base-wSknxBv7.d.ts.map +0 -1
- package/dist/internals/chunk-BuMQw4dz.js.map +0 -1
- package/dist/internals/chunk-C_BXf1Er.d.ts.map +0 -1
- package/dist/internals/chunk-DxYhYVky.mjs.map +0 -1
- package/dist/internals/index-A-hoMfDO.d.ts.map +0 -1
- package/dist/internals/index-BvwYz4Yp.mjs.map +0 -1
- package/dist/internals/index-DVUiXLfI.js.map +0 -1
- package/dist/internals/index-iqOd-Wdg.d.ts.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import { F as FileChunkStorageBase } from '../../internals/chunk-
|
|
3
|
-
import '../../internals/base-
|
|
2
|
+
import { F as FileChunkStorageBase } from '../../internals/chunk-bpt1C6W4.mjs';
|
|
3
|
+
import '../../internals/base-DYc1_peK.mjs';
|
|
4
4
|
import 'util';
|
|
5
5
|
import 'zlib';
|
|
6
6
|
import '@o2ter/utils-js';
|
|
@@ -44,19 +44,29 @@ class GoogleCloudStorage extends FileChunkStorageBase {
|
|
|
44
44
|
async createChunk(proto, token, start, end, compressed) {
|
|
45
45
|
await this.bucket.file(`${token}/${start}.chunk`).save(compressed);
|
|
46
46
|
}
|
|
47
|
-
async listChunks(proto, token) {
|
|
48
|
-
|
|
47
|
+
async *listChunks(proto, token, start, end) {
|
|
48
|
+
let query = {
|
|
49
|
+
autoPaginate: false,
|
|
49
50
|
prefix: `${token}/`,
|
|
50
51
|
delimiter: '/',
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
};
|
|
53
|
+
do {
|
|
54
|
+
const [response, nextPage] = await this.bucket.getFiles(query);
|
|
55
|
+
if (_.isEmpty(response))
|
|
56
|
+
break;
|
|
57
|
+
for (const item of response) {
|
|
58
|
+
const name = _.last(_.split(item.name, '/'));
|
|
59
|
+
if (!name?.match(/^\d+\.chunk$/))
|
|
60
|
+
continue;
|
|
61
|
+
const pos = parseInt(name.slice(0, -6));
|
|
62
|
+
if (start && pos < start)
|
|
63
|
+
continue;
|
|
64
|
+
if (end && pos >= end)
|
|
65
|
+
continue;
|
|
66
|
+
yield { start: pos, file: item };
|
|
67
|
+
}
|
|
68
|
+
query = nextPage;
|
|
69
|
+
} while (query);
|
|
60
70
|
}
|
|
61
71
|
async readChunk(proto, file) {
|
|
62
72
|
const [buffer] = await file.download() ?? [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-cloud-storage.mjs","sources":["../../../../src/adapters/file/google-cloud-storage/index.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { ProtoService } from '../../../server/proto';\nimport { Storage, File } from '@google-cloud/storage';\nimport { FileStorageOptions } from '../base';\nimport { FileChunkStorageBase } from '../base/chunk';\n\nexport class GoogleCloudStorage extends FileChunkStorageBase<File> {\n\n private _storage: Storage;\n private _bucket: string;\n\n constructor(storage: Storage, bucket: string, options: FileStorageOptions = {}) {\n super(options);\n this._storage = storage;\n this._bucket = bucket;\n }\n\n get bucket() {\n return this._storage.bucket(this._bucket);\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n await this.bucket.file(`${token}/${start}.chunk`).save(compressed);\n }\n\n async listChunks<E>(proto: ProtoService<E>, token: string) {\n
|
|
1
|
+
{"version":3,"file":"google-cloud-storage.mjs","sources":["../../../../src/adapters/file/google-cloud-storage/index.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { ProtoService } from '../../../server/proto';\nimport { Storage, File, GetFilesOptions } from '@google-cloud/storage';\nimport { FileStorageOptions } from '../base';\nimport { FileChunkStorageBase } from '../base/chunk';\n\nexport class GoogleCloudStorage extends FileChunkStorageBase<File> {\n\n private _storage: Storage;\n private _bucket: string;\n\n constructor(storage: Storage, bucket: string, options: FileStorageOptions = {}) {\n super(options);\n this._storage = storage;\n this._bucket = bucket;\n }\n\n get bucket() {\n return this._storage.bucket(this._bucket);\n }\n\n async createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer) {\n await this.bucket.file(`${token}/${start}.chunk`).save(compressed);\n }\n\n async* listChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number) {\n let query: any = {\n autoPaginate: false,\n prefix: `${token}/`,\n delimiter: '/',\n };\n do {\n const [response, nextPage] = await this.bucket.getFiles(query);\n if (_.isEmpty(response)) break;\n for (const item of response) {\n const name = _.last(_.split(item.name, '/'));\n if (!name?.match(/^\\d+\\.chunk$/)) continue;\n const pos = parseInt(name.slice(0, -6));\n if (start && pos < start) continue;\n if (end && pos >= end) continue;\n yield { start: pos, file: item };\n }\n query = nextPage;\n } while (query);\n }\n\n async readChunk<E>(proto: ProtoService<E>, file: File) {\n const [buffer] = await file.download() ?? [];\n if (!buffer) throw Error('Unable to connect cloud storage');\n return buffer;\n }\n\n async destroy<E>(proto: ProtoService<E>, token: string) {\n await this.bucket.deleteFiles({ prefix: `${token}/` });\n }\n};\n\nexport default GoogleCloudStorage;"],"names":[],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQM,MAAO,kBAAmB,SAAQ,oBAA0B,CAAA;AAExD,IAAA,QAAQ;AACR,IAAA,OAAO;AAEf,IAAA,WAAA,CAAY,OAAgB,EAAE,MAAc,EAAE,UAA8B,EAAE,EAAA;QAC5E,KAAK,CAAC,OAAO,CAAC;AACd,QAAA,IAAI,CAAC,QAAQ,GAAG,OAAO;AACvB,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM;;AAGvB,IAAA,IAAI,MAAM,GAAA;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;;IAG3C,MAAM,WAAW,CAAI,KAAsB,EAAE,KAAa,EAAE,KAAa,EAAE,GAAW,EAAE,UAAkB,EAAA;AACxG,QAAA,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAG,EAAA,KAAK,CAAI,CAAA,EAAA,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;;IAGpE,OAAO,UAAU,CAAI,KAAsB,EAAE,KAAa,EAAE,KAAc,EAAE,GAAY,EAAA;AACtF,QAAA,IAAI,KAAK,GAAQ;AACf,YAAA,YAAY,EAAE,KAAK;YACnB,MAAM,EAAE,CAAG,EAAA,KAAK,CAAG,CAAA,CAAA;AACnB,YAAA,SAAS,EAAE,GAAG;SACf;AACD,QAAA,GAAG;AACD,YAAA,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;AAC9D,YAAA,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;gBAAE;AACzB,YAAA,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE;AAC3B,gBAAA,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAC5C,gBAAA,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,cAAc,CAAC;oBAAE;AAClC,gBAAA,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACvC,gBAAA,IAAI,KAAK,IAAI,GAAG,GAAG,KAAK;oBAAE;AAC1B,gBAAA,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG;oBAAE;gBACvB,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE;;YAElC,KAAK,GAAG,QAAQ;SACjB,QAAQ,KAAK;;AAGhB,IAAA,MAAM,SAAS,CAAI,KAAsB,EAAE,IAAU,EAAA;QACnD,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE;AAC5C,QAAA,IAAI,CAAC,MAAM;AAAE,YAAA,MAAM,KAAK,CAAC,iCAAiC,CAAC;AAC3D,QAAA,OAAO,MAAM;;AAGf,IAAA,MAAM,OAAO,CAAI,KAAsB,EAAE,KAAa,EAAA;AACpD,QAAA,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAG,EAAA,KAAK,CAAG,CAAA,CAAA,EAAE,CAAC;;AAEzD;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Pool, PoolClient, PoolConfig } from 'pg';
|
|
2
|
-
import { a as TValueWithoutObject, T as TSchema, u as TValueWithUndefined, v as TValue, w as TUpdateOp, F as FieldSelectorExpression, Q as QueryExpression, R as RelationOptions, x as QuerySelector, y as DecodedSortOption, z as DecodedQuery, A as FindOptions, I as InsertOptions, B as TStorage, C as TransactionOptions, j as TObject, G as TQueryRandomOptions, H as TPubSub } from '../../internals/index-
|
|
2
|
+
import { a as TValueWithoutObject, T as TSchema, u as TValueWithUndefined, v as TValue, w as TUpdateOp, F as FieldSelectorExpression, Q as QueryExpression, R as RelationOptions, x as QuerySelector, y as DecodedSortOption, z as DecodedQuery, A as FindOptions, I as InsertOptions, B as TStorage, C as TransactionOptions, j as TObject, G as TQueryRandomOptions, H as TPubSub } from '../../internals/index-Dn1IkLDx.js';
|
|
3
3
|
import * as _o2ter_utils_js from '@o2ter/utils-js';
|
|
4
4
|
import { asyncStream } from '@o2ter/utils-js';
|
|
5
5
|
import 'jsonwebtoken';
|
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { P as ProtoClient } from './internals/index-
|
|
2
|
-
export { c as classExtends, e as isFile, f as isJob, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-
|
|
1
|
+
import { P as ProtoClient } from './internals/index-Dx36qTUa.js';
|
|
2
|
+
export { c as classExtends, e as isFile, f as isJob, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-Dx36qTUa.js';
|
|
3
3
|
export { Decimal } from 'decimal.js';
|
|
4
|
-
export { D as DeserializeOptions, S as SerializeOptions, e as TNumber, f as TSerializable, g as deserialize, s as serialize } from './internals/index-
|
|
4
|
+
export { D as DeserializeOptions, S as SerializeOptions, e as TNumber, f as TSerializable, g as deserialize, s as serialize } from './internals/index-Dn1IkLDx.js';
|
|
5
5
|
import '@o2ter/utils-js';
|
|
6
6
|
import 'socket.io-client';
|
|
7
7
|
import '@socket.io/component-emitter';
|
package/dist/client.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./internals/index-
|
|
5
|
+
var index = require('./internals/index-CK1snZyh.js');
|
|
6
6
|
var Decimal = require('decimal.js');
|
|
7
7
|
require('@o2ter/utils-js');
|
|
8
8
|
require('./internals/private-Ciddhure.js');
|
package/dist/client.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as ProtoClient } from './internals/index-
|
|
2
|
-
export { f as classExtends, d as deserialize, k as isFile, l as isJob, g as isObject, i as isQuery, j as isRole, h as isUser, s as serialize } from './internals/index-
|
|
1
|
+
import { e as ProtoClient } from './internals/index-Eo70ZAdZ.mjs';
|
|
2
|
+
export { f as classExtends, d as deserialize, k as isFile, l as isJob, g as isObject, i as isQuery, j as isRole, h as isUser, s as serialize } from './internals/index-Eo70ZAdZ.mjs';
|
|
3
3
|
export { Decimal } from 'decimal.js';
|
|
4
4
|
import '@o2ter/utils-js';
|
|
5
5
|
import './internals/private-CNw40LZ7.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as socket_io from 'socket.io';
|
|
2
2
|
import { Router } from 'express';
|
|
3
3
|
import { Server } from '@o2ter/server-js';
|
|
4
|
-
import { T as TSchema, a as TValueWithoutObject, P as ProtoService, b as ProtoServiceOptions, c as ProtoServiceKeyOptions } from './internals/index-
|
|
5
|
-
export { D as DeserializeOptions, S as SerializeOptions, d as TFileStorage, e as TNumber, f as TSerializable, g as deserialize, s as serialize } from './internals/index-
|
|
4
|
+
import { T as TSchema, a as TValueWithoutObject, P as ProtoService, b as ProtoServiceOptions, c as ProtoServiceKeyOptions } from './internals/index-Dn1IkLDx.js';
|
|
5
|
+
export { D as DeserializeOptions, S as SerializeOptions, d as TFileStorage, e as TNumber, f as TSerializable, g as deserialize, s as serialize } from './internals/index-Dn1IkLDx.js';
|
|
6
6
|
import Decimal from 'decimal.js';
|
|
7
7
|
export { Decimal } from 'decimal.js';
|
|
8
|
-
export { P as ProtoClient, c as classExtends, e as isFile, f as isJob, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-
|
|
8
|
+
export { P as ProtoClient, c as classExtends, e as isFile, f as isJob, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-Dx36qTUa.js';
|
|
9
9
|
import '@o2ter/utils-js';
|
|
10
10
|
import 'jsonwebtoken';
|
|
11
11
|
import 'lodash';
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var serverJs = require('@o2ter/server-js');
|
|
|
7
7
|
var random = require('./internals/random-B0V0EnjP.js');
|
|
8
8
|
var _private = require('./internals/private-Ciddhure.js');
|
|
9
9
|
var utilsJs = require('@o2ter/utils-js');
|
|
10
|
-
var index = require('./internals/index-
|
|
10
|
+
var index = require('./internals/index-CK1snZyh.js');
|
|
11
11
|
var index$1 = require('./internals/index-B8TESzd9.js');
|
|
12
12
|
var jwt = require('jsonwebtoken');
|
|
13
13
|
var node_buffer = require('node:buffer');
|
|
@@ -333,7 +333,7 @@ class _ProtoQuery extends index.TQuery {
|
|
|
333
333
|
await tragger(proxy(Object.setPrototypeOf({ object: obj }, this._proto)));
|
|
334
334
|
}
|
|
335
335
|
catch (e) {
|
|
336
|
-
|
|
336
|
+
this._proto.logger.error(e);
|
|
337
337
|
}
|
|
338
338
|
})();
|
|
339
339
|
}
|
|
@@ -348,7 +348,7 @@ class _ProtoQuery extends index.TQuery {
|
|
|
348
348
|
await tragger(proxy(Object.setPrototypeOf({ object: obj }, this._proto)));
|
|
349
349
|
}
|
|
350
350
|
catch (e) {
|
|
351
|
-
|
|
351
|
+
this._proto.logger.error(e);
|
|
352
352
|
}
|
|
353
353
|
})();
|
|
354
354
|
}
|
|
@@ -975,7 +975,7 @@ class ProtoInternal {
|
|
|
975
975
|
await proto.fileStorage.destroy(proto, id);
|
|
976
976
|
}
|
|
977
977
|
catch (e) {
|
|
978
|
-
|
|
978
|
+
proto.logger.error(e);
|
|
979
979
|
}
|
|
980
980
|
})();
|
|
981
981
|
}
|
|
@@ -1031,7 +1031,7 @@ class ProtoInternal {
|
|
|
1031
1031
|
}
|
|
1032
1032
|
}
|
|
1033
1033
|
catch (e) {
|
|
1034
|
-
|
|
1034
|
+
proto.logger.error(e);
|
|
1035
1035
|
}
|
|
1036
1036
|
})();
|
|
1037
1037
|
}),
|
|
@@ -1361,7 +1361,7 @@ const schedule = (proto) => {
|
|
|
1361
1361
|
await task(proto);
|
|
1362
1362
|
}
|
|
1363
1363
|
catch (e) {
|
|
1364
|
-
|
|
1364
|
+
proto.logger.error(`Errors on schedule ${op}: ${e}`);
|
|
1365
1365
|
}
|
|
1366
1366
|
}
|
|
1367
1367
|
running = false;
|
|
@@ -1431,6 +1431,7 @@ class ProtoService extends index.ProtoType {
|
|
|
1431
1431
|
keySize: 64,
|
|
1432
1432
|
saltSize: 64,
|
|
1433
1433
|
},
|
|
1434
|
+
logger: {},
|
|
1434
1435
|
...options,
|
|
1435
1436
|
});
|
|
1436
1437
|
}
|
|
@@ -1438,6 +1439,21 @@ class ProtoService extends index.ProtoType {
|
|
|
1438
1439
|
this._schedule.destroy();
|
|
1439
1440
|
this[_private.PVK].shutdown();
|
|
1440
1441
|
}
|
|
1442
|
+
get logger() {
|
|
1443
|
+
const logger = this[_private.PVK].options.logger;
|
|
1444
|
+
const loggerLevel = logger.loggerLevel ?? 'warn';
|
|
1445
|
+
const callbacks = _.map(index._logLevels, (x, i) => [x, (...args) => {
|
|
1446
|
+
if (loggerLevel !== 'all' && _.indexOf(index._logLevels, loggerLevel) < i)
|
|
1447
|
+
return;
|
|
1448
|
+
const func = logger[x] ?? console[x];
|
|
1449
|
+
if (_.isFunction(func))
|
|
1450
|
+
func(...args);
|
|
1451
|
+
}]);
|
|
1452
|
+
return {
|
|
1453
|
+
loggerLevel,
|
|
1454
|
+
..._.fromPairs(callbacks),
|
|
1455
|
+
};
|
|
1456
|
+
}
|
|
1441
1457
|
classes() {
|
|
1442
1458
|
return _.keys(this[_private.PVK].options.schema);
|
|
1443
1459
|
}
|
|
@@ -1701,7 +1717,7 @@ var authHandler = (proto) => async (req, res, next) => {
|
|
|
1701
1717
|
return next();
|
|
1702
1718
|
}
|
|
1703
1719
|
catch (e) {
|
|
1704
|
-
|
|
1720
|
+
proto.logger.error(e);
|
|
1705
1721
|
return next(new Error('Internal server error'));
|
|
1706
1722
|
}
|
|
1707
1723
|
};
|
|
@@ -2154,7 +2170,7 @@ var filesRoute = (router, proto) => {
|
|
|
2154
2170
|
res.setHeader('Content-Length', endBytes - startBytes + 1);
|
|
2155
2171
|
res.setHeader('Content-Range', `bytes ${startBytes}-${endBytes}/${file.size}`);
|
|
2156
2172
|
res.status(206);
|
|
2157
|
-
stream = payload.fileStorage.fileData(payload, file.token, startBytes, endBytes);
|
|
2173
|
+
stream = payload.fileStorage.fileData(payload, file.token, startBytes, endBytes + 1);
|
|
2158
2174
|
}
|
|
2159
2175
|
else {
|
|
2160
2176
|
res.setHeader('Content-Length', file.size);
|
|
@@ -2525,7 +2541,7 @@ const registerProtoSocket = (proto, server, endpoint) => {
|
|
|
2525
2541
|
return index$2.QuerySelector.decode(v);
|
|
2526
2542
|
}
|
|
2527
2543
|
catch (error) {
|
|
2528
|
-
|
|
2544
|
+
proto.logger.error(error);
|
|
2529
2545
|
return false;
|
|
2530
2546
|
}
|
|
2531
2547
|
});
|