proto.io 0.0.205 → 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/database.d.ts +2 -2
- package/dist/adapters/file/database.js +2 -2
- package/dist/adapters/file/database.mjs +2 -2
- package/dist/adapters/file/filesystem.d.ts +3 -3
- package/dist/adapters/file/google-cloud-storage.d.ts +3 -3
- 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 +30 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -12
- package/dist/index.mjs.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/{chunk-ONaLyXL0.d.ts → chunk-CEQtSsWb.d.ts} +3 -3
- package/dist/internals/chunk-CEQtSsWb.d.ts.map +1 -0
- 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
|
}
|
|
@@ -2513,10 +2516,13 @@ const ProtoRoute = async (options) => {
|
|
|
2513
2516
|
const registerProtoSocket = (proto, server, endpoint) => {
|
|
2514
2517
|
const io = endpoint ? server.socket().of(endpoint) : server.socket();
|
|
2515
2518
|
io.on('connection', async (socket) => {
|
|
2519
|
+
let listeners = {};
|
|
2516
2520
|
const connect = async (token) => {
|
|
2517
2521
|
const payload = await proto.connectWithSessionToken(token);
|
|
2518
2522
|
const { remove } = payload.listen(data => {
|
|
2519
|
-
|
|
2523
|
+
const ids = _.keys(_.pickBy(listeners, v => v instanceof QuerySelector ? v.eval(data) : v));
|
|
2524
|
+
if (!_.isEmpty(ids))
|
|
2525
|
+
socket.emit('data', { ids, data });
|
|
2520
2526
|
});
|
|
2521
2527
|
return remove;
|
|
2522
2528
|
};
|
|
@@ -2529,6 +2535,19 @@ const registerProtoSocket = (proto, server, endpoint) => {
|
|
|
2529
2535
|
socket.on('disconnect', () => {
|
|
2530
2536
|
remove.then(rm => rm());
|
|
2531
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
|
+
});
|
|
2532
2551
|
});
|
|
2533
2552
|
return io;
|
|
2534
2553
|
};
|