proto.io 0.0.204 → 0.0.206
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 +3 -3
- package/dist/adapters/file/aliyun-oss.js +2 -2
- package/dist/adapters/file/aliyun-oss.mjs +2 -2
- package/dist/adapters/file/database.d.ts +2 -2
- package/dist/adapters/file/database.js +3 -3
- package/dist/adapters/file/database.mjs +3 -3
- package/dist/adapters/file/filesystem.d.ts +3 -3
- package/dist/adapters/file/filesystem.js +2 -2
- package/dist/adapters/file/filesystem.mjs +2 -2
- package/dist/adapters/file/google-cloud-storage.d.ts +3 -3
- package/dist/adapters/file/google-cloud-storage.js +2 -2
- package/dist/adapters/file/google-cloud-storage.mjs +2 -2
- package/dist/adapters/storage/progres.d.ts +5 -8
- package/dist/adapters/storage/progres.js +13 -17
- package/dist/adapters/storage/progres.js.map +1 -1
- package/dist/adapters/storage/progres.mjs +13 -17
- package/dist/adapters/storage/progres.mjs.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js +3 -2
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +4 -3
- package/dist/client.mjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +33 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -13
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{base-NsJYo2MG.js → base-BFKQpiws.js} +3 -3
- package/dist/internals/{base-NsJYo2MG.js.map → base-BFKQpiws.js.map} +1 -1
- package/dist/internals/{base-Cf7WkDhO.d.ts → base-Be7PFKEC.d.ts} +2 -2
- package/dist/internals/base-Be7PFKEC.d.ts.map +1 -0
- package/dist/internals/{base-DYc1_peK.mjs → base-CfQi0T0I.mjs} +3 -3
- package/dist/internals/{base-DYc1_peK.mjs.map → base-CfQi0T0I.mjs.map} +1 -1
- package/dist/internals/{chunk-CdEGTub2.js → chunk-BuMQw4dz.js} +2 -2
- package/dist/internals/{chunk-CdEGTub2.js.map → chunk-BuMQw4dz.js.map} +1 -1
- package/dist/internals/{chunk-ONaLyXL0.d.ts → chunk-CEQtSsWb.d.ts} +3 -3
- package/dist/internals/chunk-CEQtSsWb.d.ts.map +1 -0
- package/dist/internals/{chunk-3nNdftWC.mjs → chunk-DxYhYVky.mjs} +2 -2
- package/dist/internals/{chunk-3nNdftWC.mjs.map → chunk-DxYhYVky.mjs.map} +1 -1
- package/dist/internals/{index-DByHjIHI.js → index-BFZlY3IO.js} +23 -23
- package/dist/internals/index-BFZlY3IO.js.map +1 -0
- package/dist/internals/{index-DtCgllhg.mjs → index-CSnRU_KQ.mjs} +23 -23
- package/dist/internals/index-CSnRU_KQ.mjs.map +1 -0
- package/dist/internals/{index-DI-jPA6f.d.ts → index-CURcwPBG.d.ts} +3 -3
- package/dist/internals/index-CURcwPBG.d.ts.map +1 -0
- package/dist/internals/{index-B8TESzd9.js → index-CsmAYB_t.js} +2 -1
- package/dist/internals/{index-B8TESzd9.js.map → index-CsmAYB_t.js.map} +1 -1
- package/dist/internals/{index-C4vwSN74.js → index-CyPxh5dl.js} +241 -2
- package/dist/internals/index-CyPxh5dl.js.map +1 -0
- package/dist/internals/{index-JdEs5VLY.d.ts → index-DnbbpIaO.d.ts} +15 -18
- package/dist/internals/index-DnbbpIaO.d.ts.map +1 -0
- package/dist/internals/{index-al1N-qi7.mjs → index-DpN9tcbY.mjs} +2 -2
- package/dist/internals/{index-al1N-qi7.mjs.map → index-DpN9tcbY.mjs.map} +1 -1
- package/dist/internals/{index-Blw7vAq5.mjs → index-iRVgw566.mjs} +241 -2
- package/dist/internals/index-iRVgw566.mjs.map +1 -0
- package/dist/internals/{random-6nHcBOxn.mjs → random-BnGB_bVS.mjs} +3 -3
- package/dist/internals/{random-6nHcBOxn.mjs.map → random-BnGB_bVS.mjs.map} +1 -1
- package/dist/internals/{random-Dk3OhDNU.js → random-D7S1XD7F.js} +3 -3
- package/dist/internals/{random-Dk3OhDNU.js.map → random-D7S1XD7F.js.map} +1 -1
- package/package.json +1 -1
- package/dist/internals/base-Cf7WkDhO.d.ts.map +0 -1
- package/dist/internals/chunk-ONaLyXL0.d.ts.map +0 -1
- package/dist/internals/index-Blw7vAq5.mjs.map +0 -1
- package/dist/internals/index-C4vwSN74.js.map +0 -1
- package/dist/internals/index-DByHjIHI.js.map +0 -1
- package/dist/internals/index-DI-jPA6f.d.ts.map +0 -1
- package/dist/internals/index-DtCgllhg.mjs.map +0 -1
- package/dist/internals/index-JdEs5VLY.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { Server } from '@o2ter/server-js';
|
|
3
|
-
import { Q as QueryValidator, r as resolveColumn, a as resolveDataType, g as generateId } from './internals/random-
|
|
3
|
+
import { Q as QueryValidator, r as resolveColumn, a as resolveDataType, g as generateId } from './internals/random-BnGB_bVS.mjs';
|
|
4
4
|
import { P as PVK } from './internals/private-CNw40LZ7.mjs';
|
|
5
5
|
import { asyncStream, prototypes, isBinaryData, base64ToBuffer } from '@o2ter/utils-js';
|
|
6
|
-
import { T as TQuery, d as deserialize, P as PROTO_NOTY_MSG, M as MASTER_USER_HEADER_NAME, a as MASTER_PASS_HEADER_NAME, A as AUTH_COOKIE_KEY, b as TUser, c as ProtoType, s as serialize, U as UPLOAD_TOKEN_HEADER_NAME } from './internals/index-
|
|
7
|
-
export { e as ProtoClient, f as classExtends, k as isFile, l as isJob, g as isObject, i as isQuery, j as isRole, h as isUser } from './internals/index-
|
|
8
|
-
import { i as isPointer, a as isRelation, T as TObject, b as isShape, d as defaultObjectKeyTypes, c as isPrimitive } from './internals/index-
|
|
6
|
+
import { T as TQuery, d as deserialize, P as PROTO_NOTY_MSG, M as MASTER_USER_HEADER_NAME, a as MASTER_PASS_HEADER_NAME, A as AUTH_COOKIE_KEY, b as TUser, c as ProtoType, s as serialize, U as UPLOAD_TOKEN_HEADER_NAME } from './internals/index-CSnRU_KQ.mjs';
|
|
7
|
+
export { e as ProtoClient, f as classExtends, k as isFile, l as isJob, g as isObject, i as isQuery, j as isRole, h as isUser } from './internals/index-CSnRU_KQ.mjs';
|
|
8
|
+
import { i as isPointer, a as isRelation, T as TObject, b as isShape, d as defaultObjectKeyTypes, c as isPrimitive } from './internals/index-DpN9tcbY.mjs';
|
|
9
9
|
import jwt from 'jsonwebtoken';
|
|
10
10
|
import { Blob } from 'node:buffer';
|
|
11
11
|
import { Readable } from 'node:stream';
|
|
@@ -13,7 +13,7 @@ import { scrypt } from 'node:crypto';
|
|
|
13
13
|
import { promisify } from 'util';
|
|
14
14
|
import { randomBytes, randomUUID } from '@o2ter/crypto-js';
|
|
15
15
|
export { Decimal } from 'decimal.js';
|
|
16
|
-
import { Q as QuerySelector } from './internals/index-
|
|
16
|
+
import { Q as QuerySelector } from './internals/index-iRVgw566.mjs';
|
|
17
17
|
import queryType from 'query-types';
|
|
18
18
|
import busboy from 'busboy';
|
|
19
19
|
import 'axios';
|
|
@@ -355,18 +355,18 @@ class _ProtoQuery extends TQuery {
|
|
|
355
355
|
return result;
|
|
356
356
|
}
|
|
357
357
|
async insertMany(values, options) {
|
|
358
|
-
return this._dispatcher(options).insertMany({
|
|
358
|
+
return this._objectMethods(await this._dispatcher(options).insertMany({
|
|
359
359
|
className: this.className,
|
|
360
360
|
includes: this[PVK].options.includes,
|
|
361
361
|
matches: this[PVK].options.matches,
|
|
362
362
|
countMatches: this[PVK].options.countMatches,
|
|
363
|
-
}, values);
|
|
363
|
+
}, values));
|
|
364
364
|
}
|
|
365
365
|
async updateOne(update, options) {
|
|
366
366
|
return this._objectMethods(await this._dispatcher(options).updateOne(this._queryOptions, update));
|
|
367
367
|
}
|
|
368
368
|
async updateMany(update, options) {
|
|
369
|
-
return this._dispatcher(options).updateMany(this._queryOptions, update);
|
|
369
|
+
return this._objectMethods(await this._dispatcher(options).updateMany(this._queryOptions, update));
|
|
370
370
|
}
|
|
371
371
|
async upsertOne(update, setOnInsert, options) {
|
|
372
372
|
const result = this._objectMethods(await this._dispatcher(options).upsertOne(this._queryOptions, update, setOnInsert));
|
|
@@ -375,13 +375,13 @@ class _ProtoQuery extends TQuery {
|
|
|
375
375
|
return result;
|
|
376
376
|
}
|
|
377
377
|
async upsertMany(update, setOnInsert, options) {
|
|
378
|
-
return this._dispatcher(options).upsertMany(this._queryOptions, update, setOnInsert);
|
|
378
|
+
return this._objectMethods(await this._dispatcher(options).upsertMany(this._queryOptions, update, setOnInsert));
|
|
379
379
|
}
|
|
380
380
|
async deleteOne(options) {
|
|
381
381
|
return this._objectMethods(await this._dispatcher(options).deleteOne(this._queryOptions));
|
|
382
382
|
}
|
|
383
383
|
async deleteMany(options) {
|
|
384
|
-
return this._dispatcher(options).deleteMany(this._queryOptions);
|
|
384
|
+
return this._objectMethods(await this._dispatcher(options).deleteMany(this._queryOptions));
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
387
|
class ProtoQuery extends _ProtoQuery {
|
|
@@ -1640,8 +1640,11 @@ class ProtoService extends ProtoType {
|
|
|
1640
1640
|
notify(data) {
|
|
1641
1641
|
return this[PVK].notify(this, data);
|
|
1642
1642
|
}
|
|
1643
|
-
listen(callback) {
|
|
1643
|
+
listen(callback, selector) {
|
|
1644
|
+
const _selector = !_.isNil(selector) ? QuerySelector.decode(selector) : undefined;
|
|
1644
1645
|
return this[PVK].listen(this, data => {
|
|
1646
|
+
if (_selector && !_selector.eval(data))
|
|
1647
|
+
return;
|
|
1645
1648
|
callback(data);
|
|
1646
1649
|
});
|
|
1647
1650
|
}
|
|
@@ -2165,12 +2168,14 @@ var filesRoute = (router, proto) => {
|
|
|
2165
2168
|
let stream;
|
|
2166
2169
|
if (_.isArray(ranges) && ranges.type === 'bytes') {
|
|
2167
2170
|
const startBytes = _.minBy(ranges, r => r.start)?.start ?? 0;
|
|
2168
|
-
const endBytes = _.maxBy(ranges, r => r.end)?.end ?? file.size;
|
|
2171
|
+
const endBytes = _.maxBy(ranges, r => r.end)?.end ?? (file.size - 1);
|
|
2172
|
+
res.setHeader('Content-Length', endBytes - startBytes + 1);
|
|
2169
2173
|
res.setHeader('Content-Range', `bytes ${startBytes}-${endBytes}/${file.size}`);
|
|
2170
2174
|
res.status(206);
|
|
2171
2175
|
stream = payload.fileStorage.fileData(payload, file.token, startBytes, endBytes);
|
|
2172
2176
|
}
|
|
2173
2177
|
else {
|
|
2178
|
+
res.setHeader('Content-Length', file.size);
|
|
2174
2179
|
res.status(200);
|
|
2175
2180
|
stream = payload.fileStorage.fileData(payload, file.token);
|
|
2176
2181
|
}
|
|
@@ -2511,10 +2516,13 @@ const ProtoRoute = async (options) => {
|
|
|
2511
2516
|
const registerProtoSocket = (proto, server, endpoint) => {
|
|
2512
2517
|
const io = endpoint ? server.socket().of(endpoint) : server.socket();
|
|
2513
2518
|
io.on('connection', async (socket) => {
|
|
2519
|
+
let listeners = {};
|
|
2514
2520
|
const connect = async (token) => {
|
|
2515
2521
|
const payload = await proto.connectWithSessionToken(token);
|
|
2516
2522
|
const { remove } = payload.listen(data => {
|
|
2517
|
-
|
|
2523
|
+
const ids = _.keys(_.pickBy(listeners, v => v instanceof QuerySelector ? v.eval(data) : v));
|
|
2524
|
+
if (!_.isEmpty(ids))
|
|
2525
|
+
socket.emit('data', { ids, data });
|
|
2518
2526
|
});
|
|
2519
2527
|
return remove;
|
|
2520
2528
|
};
|
|
@@ -2527,6 +2535,19 @@ const registerProtoSocket = (proto, server, endpoint) => {
|
|
|
2527
2535
|
socket.on('disconnect', () => {
|
|
2528
2536
|
remove.then(rm => rm());
|
|
2529
2537
|
});
|
|
2538
|
+
socket.on('register', (payload) => {
|
|
2539
|
+
listeners = _.mapValues(payload, v => {
|
|
2540
|
+
if (_.isBoolean(v))
|
|
2541
|
+
return true;
|
|
2542
|
+
try {
|
|
2543
|
+
return QuerySelector.decode(v);
|
|
2544
|
+
}
|
|
2545
|
+
catch (error) {
|
|
2546
|
+
console.error(error);
|
|
2547
|
+
return false;
|
|
2548
|
+
}
|
|
2549
|
+
});
|
|
2550
|
+
});
|
|
2530
2551
|
});
|
|
2531
2552
|
return io;
|
|
2532
2553
|
};
|