proto.io 0.0.223 → 0.0.224
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 +1 -1
- package/dist/adapters/file/database.mjs +1 -1
- 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 +1 -1
- package/dist/adapters/storage/progres.js +3 -3
- package/dist/adapters/storage/progres.js.map +1 -1
- package/dist/adapters/storage/progres.mjs +3 -3
- package/dist/adapters/storage/progres.mjs.map +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 +53 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -52
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{base-D7eiLTdl.d.ts → base-NZIvB1zK.d.ts} +2 -2
- package/dist/internals/base-NZIvB1zK.d.ts.map +1 -0
- package/dist/internals/{chunk-B95QS-B7.d.ts → chunk-B9i8NMB_.d.ts} +3 -3
- package/dist/internals/chunk-B9i8NMB_.d.ts.map +1 -0
- package/dist/internals/{index-B9kyejqo.d.ts → index-BOboD1oK.d.ts} +84 -35
- package/dist/internals/index-BOboD1oK.d.ts.map +1 -0
- package/dist/internals/{index-BozJOOCD.mjs → index-BZ79Ljis.mjs} +12 -1
- package/dist/internals/index-BZ79Ljis.mjs.map +1 -0
- package/dist/internals/{index-DRgs8WkW.d.ts → index-BcNiVp-e.d.ts} +3 -2
- package/dist/internals/index-BcNiVp-e.d.ts.map +1 -0
- package/dist/internals/index-CLKTEIj0.js.map +1 -1
- package/dist/internals/index-gWcE22mf.mjs.map +1 -1
- package/dist/internals/{index-C01HL8O6.js → index-vOFh8pVc.js} +12 -1
- package/dist/internals/index-vOFh8pVc.js.map +1 -0
- package/dist/internals/{validator-DX2nXeQo.mjs → validator-0I1kvhsL.mjs} +42 -10
- package/dist/internals/validator-0I1kvhsL.mjs.map +1 -0
- package/dist/internals/{validator-B5yHpyvb.js → validator-Bc1jRJfA.js} +42 -10
- package/dist/internals/validator-Bc1jRJfA.js.map +1 -0
- package/package.json +1 -1
- package/dist/internals/base-D7eiLTdl.d.ts.map +0 -1
- package/dist/internals/chunk-B95QS-B7.d.ts.map +0 -1
- package/dist/internals/index-B9kyejqo.d.ts.map +0 -1
- package/dist/internals/index-BozJOOCD.mjs.map +0 -1
- package/dist/internals/index-C01HL8O6.js.map +0 -1
- package/dist/internals/index-DRgs8WkW.d.ts.map +0 -1
- package/dist/internals/validator-B5yHpyvb.js.map +0 -1
- package/dist/internals/validator-DX2nXeQo.mjs.map +0 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProtoClient } from './internals/index-
|
|
2
|
-
export { c as classExtends } from './internals/index-
|
|
3
|
-
export { D as DeserializeOptions, S as SerializeOptions, e as TNumber, f as TSerializable, g as deserialize, s as serialize } from './internals/index-
|
|
1
|
+
import { P as ProtoClient } from './internals/index-BcNiVp-e.js';
|
|
2
|
+
export { c as classExtends } from './internals/index-BcNiVp-e.js';
|
|
3
|
+
export { D as DeserializeOptions, S as SerializeOptions, e as TNumber, f as TSerializable, g as deserialize, s as serialize } from './internals/index-BOboD1oK.js';
|
|
4
4
|
export { Decimal } from 'decimal.js';
|
|
5
5
|
import '@o2ter/utils-js';
|
|
6
6
|
import 'socket.io-client';
|
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-vOFh8pVc.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 { b as ProtoClient } from './internals/index-
|
|
2
|
-
export { c as classExtends, d as deserialize, s as serialize } from './internals/index-
|
|
1
|
+
import { b as ProtoClient } from './internals/index-BZ79Ljis.mjs';
|
|
2
|
+
export { c as classExtends, d as deserialize, s as serialize } from './internals/index-BZ79Ljis.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-BOboD1oK.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-BOboD1oK.js';
|
|
6
6
|
import Decimal from 'decimal.js';
|
|
7
7
|
export { Decimal } from 'decimal.js';
|
|
8
|
-
export { P as ProtoClient, c as classExtends } from './internals/index-
|
|
8
|
+
export { P as ProtoClient, c as classExtends } from './internals/index-BcNiVp-e.js';
|
|
9
9
|
import '@o2ter/utils-js';
|
|
10
10
|
import 'jsonwebtoken';
|
|
11
11
|
import 'lodash';
|
package/dist/index.js
CHANGED
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _ = require('lodash');
|
|
6
6
|
var serverJs = require('@o2ter/server-js');
|
|
7
|
-
var validator = require('./internals/validator-
|
|
7
|
+
var validator = require('./internals/validator-Bc1jRJfA.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-vOFh8pVc.js');
|
|
11
11
|
var index$1 = require('./internals/index-CLKTEIj0.js');
|
|
12
12
|
var jwt = require('jsonwebtoken');
|
|
13
13
|
var node_buffer = require('node:buffer');
|
|
@@ -327,7 +327,7 @@ class _ProtoQuery extends index.TQuery {
|
|
|
327
327
|
yield self._objectMethods(object);
|
|
328
328
|
});
|
|
329
329
|
}
|
|
330
|
-
|
|
330
|
+
_on_upsert_traggers(objects) {
|
|
331
331
|
const createTraggers = this._proto[_private.PVK].triggers[this.className]?.create ?? [];
|
|
332
332
|
const updateTraggers = this._proto[_private.PVK].triggers[this.className]?.update ?? [];
|
|
333
333
|
for (const obj of objects) {
|
|
@@ -342,6 +342,8 @@ class _ProtoQuery extends index.TQuery {
|
|
|
342
342
|
})();
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
|
+
}
|
|
346
|
+
_on_upsert(objects) {
|
|
345
347
|
if (this._proto.schema[this.className]?.liveQuery) {
|
|
346
348
|
(async () => {
|
|
347
349
|
try {
|
|
@@ -354,7 +356,7 @@ class _ProtoQuery extends index.TQuery {
|
|
|
354
356
|
})();
|
|
355
357
|
}
|
|
356
358
|
}
|
|
357
|
-
|
|
359
|
+
_on_delete_traggers(objects) {
|
|
358
360
|
const traggers = this._proto[_private.PVK].triggers[this.className]?.delete ?? [];
|
|
359
361
|
for (const obj of objects) {
|
|
360
362
|
for (const tragger of traggers) {
|
|
@@ -368,6 +370,8 @@ class _ProtoQuery extends index.TQuery {
|
|
|
368
370
|
})();
|
|
369
371
|
}
|
|
370
372
|
}
|
|
373
|
+
}
|
|
374
|
+
_on_delete(objects) {
|
|
371
375
|
if (this._proto.schema[this.className]?.liveQuery) {
|
|
372
376
|
(async () => {
|
|
373
377
|
try {
|
|
@@ -386,26 +390,30 @@ class _ProtoQuery extends index.TQuery {
|
|
|
386
390
|
matches: this[_private.PVK].options.matches,
|
|
387
391
|
groupMatches: this[_private.PVK].options.groupMatches,
|
|
388
392
|
}, values));
|
|
389
|
-
|
|
390
|
-
|
|
393
|
+
this._on_upsert(objs);
|
|
394
|
+
if (!options?.silent || !options.master)
|
|
395
|
+
this._on_upsert_traggers(objs);
|
|
391
396
|
return objs;
|
|
392
397
|
}
|
|
393
398
|
async updateMany(update, options) {
|
|
394
399
|
const objs = this._objectMethods(await this._dispatcher(options).update(this._queryOptions, update));
|
|
395
|
-
|
|
396
|
-
|
|
400
|
+
this._on_upsert(objs);
|
|
401
|
+
if (!options?.silent || !options.master)
|
|
402
|
+
this._on_upsert_traggers(objs);
|
|
397
403
|
return objs;
|
|
398
404
|
}
|
|
399
405
|
async upsertMany(update, setOnInsert, options) {
|
|
400
406
|
const objs = this._objectMethods(await this._dispatcher(options).upsert(this._queryOptions, update, setOnInsert));
|
|
401
|
-
|
|
402
|
-
|
|
407
|
+
this._on_upsert(objs);
|
|
408
|
+
if (!options?.silent || !options.master)
|
|
409
|
+
this._on_upsert_traggers(objs);
|
|
403
410
|
return objs;
|
|
404
411
|
}
|
|
405
412
|
async deleteMany(options) {
|
|
406
413
|
const objs = this._objectMethods(await this._dispatcher(options).delete(this._queryOptions));
|
|
407
|
-
|
|
408
|
-
|
|
414
|
+
this._on_delete(objs);
|
|
415
|
+
if (!options?.silent || !options.master)
|
|
416
|
+
this._on_delete_traggers(objs);
|
|
409
417
|
return objs;
|
|
410
418
|
}
|
|
411
419
|
}
|
|
@@ -1075,14 +1083,14 @@ class ProtoInternal {
|
|
|
1075
1083
|
});
|
|
1076
1084
|
}
|
|
1077
1085
|
listen(proto, callback) {
|
|
1078
|
-
const isMaster = proto.isMaster;
|
|
1079
|
-
const roles = isMaster ? [] : this._perms(proto);
|
|
1080
1086
|
return {
|
|
1081
1087
|
remove: this.options.pubsub.subscribe(_const.PROTO_NOTY_MSG, payload => {
|
|
1082
1088
|
const { _rperm } = payload;
|
|
1083
1089
|
(async () => {
|
|
1084
1090
|
try {
|
|
1085
|
-
|
|
1091
|
+
const isMaster = proto.isMaster;
|
|
1092
|
+
const roles = isMaster ? [] : await this._perms(proto);
|
|
1093
|
+
if (!isMaster && !_.some(roles, x => _.includes(_rperm, x)))
|
|
1086
1094
|
return;
|
|
1087
1095
|
await callback(payload);
|
|
1088
1096
|
}
|
|
@@ -1099,18 +1107,17 @@ class ProtoInternal {
|
|
|
1099
1107
|
return this.options.pubsub.publish(_const.PROTO_LIVEQUERY_MSG, JSON.parse(index.serialize({ event, objects }, { objAttrs: index$1.TObject.defaultKeys })));
|
|
1100
1108
|
}
|
|
1101
1109
|
_liveQuery(proto, callback) {
|
|
1102
|
-
const isMaster = proto.isMaster;
|
|
1103
|
-
const roles = isMaster ? [] : this._perms(proto);
|
|
1104
1110
|
return {
|
|
1105
1111
|
remove: this.options.pubsub.subscribe(_const.PROTO_LIVEQUERY_MSG, payload => {
|
|
1106
1112
|
const { event, objects } = index.deserialize(JSON.stringify(payload));
|
|
1107
1113
|
(async () => {
|
|
1108
1114
|
try {
|
|
1109
|
-
const
|
|
1115
|
+
const isMaster = proto.isMaster;
|
|
1116
|
+
const roles = isMaster ? [] : await this._perms(proto);
|
|
1110
1117
|
const payload = proto.rebind(isMaster ? objects : _.filter(objects, object => {
|
|
1111
1118
|
const acl = object.acl();
|
|
1112
1119
|
const clp = proto.schema[object.className].classLevelPermissions?.get ?? ['*'];
|
|
1113
|
-
return _.some(
|
|
1120
|
+
return _.some(roles, x => _.includes(clp, x) && _.includes(acl.read, x));
|
|
1114
1121
|
}));
|
|
1115
1122
|
if (!_.isEmpty(payload))
|
|
1116
1123
|
await callback(event, payload);
|
|
@@ -2633,42 +2640,37 @@ const ProtoRoute = async (options) => {
|
|
|
2633
2640
|
const registerProtoSocket = (proto, server, endpoint) => {
|
|
2634
2641
|
const io = endpoint ? server.socket().of(endpoint) : server.socket();
|
|
2635
2642
|
io.on('connection', async (socket) => {
|
|
2643
|
+
let { token } = socket.handshake.auth;
|
|
2644
|
+
const service = await proto.connectWithSessionToken(token);
|
|
2645
|
+
socket.on('auth', (t) => {
|
|
2646
|
+
token = t;
|
|
2647
|
+
service.connectWithSessionToken(t);
|
|
2648
|
+
});
|
|
2636
2649
|
let events = {};
|
|
2637
2650
|
let queries = {};
|
|
2638
|
-
const
|
|
2639
|
-
const
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
const
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
socket.emit('ON_EV_LIVEQUERY', { ids, data: payload });
|
|
2658
|
-
});
|
|
2659
|
-
return () => {
|
|
2660
|
-
remove_basic();
|
|
2661
|
-
remove_livequery();
|
|
2662
|
-
};
|
|
2663
|
-
};
|
|
2664
|
-
const { token } = socket.handshake.auth;
|
|
2665
|
-
const service = await proto.connectWithSessionToken(token);
|
|
2666
|
-
const remove = connect(service);
|
|
2667
|
-
socket.on('auth', (token) => {
|
|
2668
|
-
service.connectWithSessionToken(token);
|
|
2651
|
+
const { remove: remove_basic } = service.listen(data => {
|
|
2652
|
+
const ids = _.keys(_.pickBy(events, v => v instanceof validator.QuerySelector ? v.eval(data) : v));
|
|
2653
|
+
const payload = JSON.parse(index.serialize(data));
|
|
2654
|
+
if (!_.isEmpty(ids))
|
|
2655
|
+
socket.emit('ON_EV_NOTIFY', { ids, data: payload });
|
|
2656
|
+
});
|
|
2657
|
+
const { remove: remove_livequery } = service[_private.PVK]._liveQuery(service, (ev, objs) => {
|
|
2658
|
+
const ids = {};
|
|
2659
|
+
for (const obj of objs) {
|
|
2660
|
+
ids[obj.id] = _.keys(_.pickBy(queries, v => {
|
|
2661
|
+
if (v.event !== ev || v.className !== obj.className)
|
|
2662
|
+
return false;
|
|
2663
|
+
return v.filter instanceof validator.QuerySelector ? v.filter.eval(obj) : v.filter;
|
|
2664
|
+
}));
|
|
2665
|
+
}
|
|
2666
|
+
if (_.isEmpty(ids))
|
|
2667
|
+
return;
|
|
2668
|
+
const payload = JSON.parse(index.serialize(_.filter(objs, obj => !_.isEmpty(ids[obj.id]))));
|
|
2669
|
+
socket.emit('ON_EV_LIVEQUERY', { ids, data: payload });
|
|
2669
2670
|
});
|
|
2670
2671
|
socket.on('disconnect', () => {
|
|
2671
|
-
|
|
2672
|
+
remove_basic();
|
|
2673
|
+
remove_livequery();
|
|
2672
2674
|
});
|
|
2673
2675
|
socket.on('EV_NOTIFY', (payload) => {
|
|
2674
2676
|
events = _.mapValues(payload, v => {
|