proto.io 0.0.154 → 0.0.155
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/database.d.ts +2 -2
- package/dist/adapters/file/filesystem.d.ts +2 -2
- package/dist/adapters/file/google-cloud-storage.d.ts +2 -2
- package/dist/adapters/storage/progres.d.ts +11 -7
- package/dist/adapters/storage/progres.js +55 -14
- package/dist/adapters/storage/progres.js.map +1 -1
- package/dist/adapters/storage/progres.mjs +55 -14
- 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 +39 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -20
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{index-c-CaNuVY.mjs → index-B01TqoO1.mjs} +19 -4
- package/dist/internals/index-B01TqoO1.mjs.map +1 -0
- package/dist/internals/{index-BeRyWUVp.d.ts → index-BLVOKfv3.d.ts} +15 -6
- package/dist/internals/index-BLVOKfv3.d.ts.map +1 -0
- package/dist/internals/{index-D1YGwuNK.js → index-Bs06MNCK.js} +19 -4
- package/dist/internals/index-Bs06MNCK.js.map +1 -0
- package/dist/internals/{index-rx1BTcvL.d.ts → index-DSU589g6.d.ts} +2 -2
- package/dist/internals/index-DSU589g6.d.ts.map +1 -0
- package/dist/internals/{index-DI0coKnM.d.ts → index-DmcvF1dx.d.ts} +3 -2
- package/dist/internals/index-DmcvF1dx.d.ts.map +1 -0
- package/dist/internals/{random-KZTFMK9-.mjs → random-DXre8Q46.mjs} +11 -1
- package/dist/internals/random-DXre8Q46.mjs.map +1 -0
- package/dist/internals/{random-DBDmz54D.js → random-DfnhGdY1.js} +11 -1
- package/dist/internals/random-DfnhGdY1.js.map +1 -0
- package/package.json +1 -1
- package/dist/internals/index-BeRyWUVp.d.ts.map +0 -1
- package/dist/internals/index-D1YGwuNK.js.map +0 -1
- package/dist/internals/index-DI0coKnM.d.ts.map +0 -1
- package/dist/internals/index-c-CaNuVY.mjs.map +0 -1
- package/dist/internals/index-rx1BTcvL.d.ts.map +0 -1
- package/dist/internals/random-DBDmz54D.js.map +0 -1
- package/dist/internals/random-KZTFMK9-.mjs.map +0 -1
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, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-
|
|
1
|
+
import { P as ProtoClient } from './internals/index-DmcvF1dx.js';
|
|
2
|
+
export { c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-DmcvF1dx.js';
|
|
3
3
|
export { Decimal } from 'decimal.js';
|
|
4
|
-
export { D as DeserializeOptions, S as SerializeOptions, d as TSerializable, e as deserialize, s as serialize } from './internals/index-
|
|
4
|
+
export { D as DeserializeOptions, S as SerializeOptions, d as TSerializable, e as deserialize, s as serialize } from './internals/index-BLVOKfv3.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-Bs06MNCK.js');
|
|
6
6
|
var Decimal = require('decimal.js');
|
|
7
7
|
require('./internals/index-CVutVPmd.js');
|
|
8
8
|
require('lodash');
|
package/dist/client.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as ProtoClient } from './internals/index-
|
|
2
|
-
export { e as classExtends, d as deserialize, j as isFile, f as isObject, i as isQuery, h as isRole, g as isUser, s as serialize } from './internals/index-
|
|
1
|
+
import { c as ProtoClient } from './internals/index-B01TqoO1.mjs';
|
|
2
|
+
export { e as classExtends, d as deserialize, j as isFile, f as isObject, i as isQuery, h as isRole, g as isUser, s as serialize } from './internals/index-B01TqoO1.mjs';
|
|
3
3
|
export { Decimal } from 'decimal.js';
|
|
4
4
|
import './internals/index-BmRuvHVZ.mjs';
|
|
5
5
|
import 'lodash';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import * as socket_io from 'socket.io';
|
|
|
2
2
|
import * as socket_io_dist_typed_events from 'socket.io/dist/typed-events';
|
|
3
3
|
import * as express_serve_static_core from 'express-serve-static-core';
|
|
4
4
|
import { Server, RequestHandler } from '@o2ter/server-js';
|
|
5
|
-
import { T as TSchema, _ as _TValue, P as ProtoService, a as ProtoServiceOptions, b as ProtoServiceKeyOptions } from './internals/index-
|
|
6
|
-
export { D as DeserializeOptions, S as SerializeOptions, c as TFileStorage, d as TSerializable, e as deserialize, s as serialize } from './internals/index-
|
|
5
|
+
import { T as TSchema, _ as _TValue, P as ProtoService, a as ProtoServiceOptions, b as ProtoServiceKeyOptions } from './internals/index-BLVOKfv3.js';
|
|
6
|
+
export { D as DeserializeOptions, S as SerializeOptions, c as TFileStorage, d as TSerializable, e as deserialize, s as serialize } from './internals/index-BLVOKfv3.js';
|
|
7
7
|
import Decimal from 'decimal.js';
|
|
8
8
|
export { Decimal } from 'decimal.js';
|
|
9
|
-
export { P as ProtoClient, c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-
|
|
9
|
+
export { P as ProtoClient, c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-DmcvF1dx.js';
|
|
10
10
|
import '@o2ter/utils-js';
|
|
11
11
|
import 'jsonwebtoken';
|
|
12
12
|
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 random = require('./internals/random-
|
|
7
|
+
var random = require('./internals/random-DfnhGdY1.js');
|
|
8
8
|
var _private = require('./internals/private-CSB1Ep4g.js');
|
|
9
9
|
var utilsJs = require('@o2ter/utils-js');
|
|
10
|
-
var index = require('./internals/index-
|
|
10
|
+
var index = require('./internals/index-Bs06MNCK.js');
|
|
11
11
|
var index$1 = require('./internals/index-CVutVPmd.js');
|
|
12
12
|
var jwt = require('jsonwebtoken');
|
|
13
13
|
var node_buffer = require('node:buffer');
|
|
@@ -295,22 +295,25 @@ const proxy = (x) => {
|
|
|
295
295
|
//
|
|
296
296
|
class ProtoQuery extends index.TQuery {
|
|
297
297
|
_proto;
|
|
298
|
-
|
|
298
|
+
_opts;
|
|
299
|
+
constructor(className, proto, opts) {
|
|
299
300
|
super(className);
|
|
300
301
|
this._proto = proto;
|
|
302
|
+
this._opts = opts;
|
|
301
303
|
}
|
|
302
304
|
get _queryOptions() {
|
|
303
305
|
return {
|
|
304
306
|
className: this.className,
|
|
307
|
+
relatedBy: this._opts.relatedBy,
|
|
305
308
|
...this[_private.PVK].options,
|
|
306
309
|
};
|
|
307
310
|
}
|
|
308
311
|
_dispatcher(options) {
|
|
309
|
-
if (this
|
|
312
|
+
if (this._opts.insecure) {
|
|
310
313
|
if (options?.master !== true)
|
|
311
314
|
throw Error('No permission');
|
|
312
315
|
}
|
|
313
|
-
return dispatcher(options?.session ?? this._proto, options ?? {}, this
|
|
316
|
+
return dispatcher(options?.session ?? this._proto, options ?? {}, !!this._opts.insecure);
|
|
314
317
|
}
|
|
315
318
|
explain(options) {
|
|
316
319
|
return this._dispatcher(options).explain(this._queryOptions);
|
|
@@ -319,7 +322,7 @@ class ProtoQuery extends index.TQuery {
|
|
|
319
322
|
return this._dispatcher(options).count(this._queryOptions);
|
|
320
323
|
}
|
|
321
324
|
clone(options) {
|
|
322
|
-
const clone = new ProtoQuery(this.className, this._proto);
|
|
325
|
+
const clone = new ProtoQuery(this.className, this._proto, this._opts);
|
|
323
326
|
clone[_private.PVK].options = options ?? { ...this[_private.PVK].options };
|
|
324
327
|
return clone;
|
|
325
328
|
}
|
|
@@ -512,13 +515,6 @@ class ProtoQuery extends index.TQuery {
|
|
|
512
515
|
return this._dispatcher(options).deleteMany(this._queryOptions);
|
|
513
516
|
}
|
|
514
517
|
}
|
|
515
|
-
class InsecureProtoQuery extends ProtoQuery {
|
|
516
|
-
clone(options) {
|
|
517
|
-
const clone = new InsecureProtoQuery(this.className, this._proto);
|
|
518
|
-
clone[_private.PVK].options = options ?? { ...this[_private.PVK].options };
|
|
519
|
-
return clone;
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
518
|
|
|
523
519
|
//
|
|
524
520
|
// defaults.ts
|
|
@@ -1348,10 +1344,22 @@ class ProtoService extends index.ProtoType {
|
|
|
1348
1344
|
return _.keys(this[_private.PVK].options.schema);
|
|
1349
1345
|
}
|
|
1350
1346
|
Query(className) {
|
|
1351
|
-
return new ProtoQuery(className, this);
|
|
1347
|
+
return new ProtoQuery(className, this, {});
|
|
1348
|
+
}
|
|
1349
|
+
Relation(className, object, key) {
|
|
1350
|
+
const objectId = object.objectId;
|
|
1351
|
+
if (!objectId)
|
|
1352
|
+
throw Error('Invalid object');
|
|
1353
|
+
return new ProtoQuery(className, this, {
|
|
1354
|
+
relatedBy: {
|
|
1355
|
+
className: object.className,
|
|
1356
|
+
objectId,
|
|
1357
|
+
key,
|
|
1358
|
+
},
|
|
1359
|
+
});
|
|
1352
1360
|
}
|
|
1353
1361
|
InsecureQuery(className) {
|
|
1354
|
-
return new
|
|
1362
|
+
return new ProtoQuery(className, this, { insecure: true });
|
|
1355
1363
|
}
|
|
1356
1364
|
get sessionId() {
|
|
1357
1365
|
if (this.session)
|
|
@@ -1616,6 +1624,16 @@ const decodeFormStream = (req, onFile) => {
|
|
|
1616
1624
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1617
1625
|
// THE SOFTWARE.
|
|
1618
1626
|
//
|
|
1627
|
+
const verifyRelatedBy = (relatedBy) => {
|
|
1628
|
+
if (!_.isPlainObject(relatedBy))
|
|
1629
|
+
return;
|
|
1630
|
+
if (!_.isString(relatedBy.className) || _.isEmpty(relatedBy.className))
|
|
1631
|
+
throw Error('Invalid option');
|
|
1632
|
+
if (!_.isString(relatedBy.objectId) || _.isEmpty(relatedBy.objectId))
|
|
1633
|
+
throw Error('Invalid option');
|
|
1634
|
+
if (!_.isString(relatedBy.key) || _.isEmpty(relatedBy.key))
|
|
1635
|
+
throw Error('Invalid option');
|
|
1636
|
+
};
|
|
1619
1637
|
var classesRoute = (router, proto) => {
|
|
1620
1638
|
router.post('/classes/:name', serverJs.Server.text({ type: '*/*' }), async (req, res) => {
|
|
1621
1639
|
res.setHeader('Cache-Control', ['no-cache', 'no-store']);
|
|
@@ -1624,9 +1642,10 @@ var classesRoute = (router, proto) => {
|
|
|
1624
1642
|
if (!_.includes(classes, name))
|
|
1625
1643
|
return res.sendStatus(404);
|
|
1626
1644
|
await response(res, async () => {
|
|
1627
|
-
const { operation, context, silent, random, attributes, update, setOnInsert, ...options } = index.deserialize(req.body);
|
|
1645
|
+
const { operation, context, silent, random, attributes, update, setOnInsert, relatedBy, ...options } = index.deserialize(req.body);
|
|
1646
|
+
verifyRelatedBy(relatedBy);
|
|
1628
1647
|
const payload = proto.connect(req);
|
|
1629
|
-
const query = payload.Query(name);
|
|
1648
|
+
const query = relatedBy ? payload.Relation(name, payload.Object(relatedBy.className, relatedBy.objectId), relatedBy.key) : payload.Query(name);
|
|
1630
1649
|
query[_private.PVK].options = options;
|
|
1631
1650
|
const opts = { master: payload.isMaster, context, silent };
|
|
1632
1651
|
switch (operation) {
|
|
@@ -1671,8 +1690,9 @@ var classesRoute = (router, proto) => {
|
|
|
1671
1690
|
});
|
|
1672
1691
|
const createQuery = (payload, req, checkLimit) => {
|
|
1673
1692
|
const { name } = req.params;
|
|
1674
|
-
const
|
|
1675
|
-
|
|
1693
|
+
const { filter, sort, includes, skip, limit, relatedBy, } = req.query;
|
|
1694
|
+
verifyRelatedBy(relatedBy);
|
|
1695
|
+
const query = relatedBy ? payload.Relation(name, payload.Object(relatedBy.className, relatedBy.objectId), relatedBy.key) : payload.Query(name);
|
|
1676
1696
|
query[_private.PVK].options.filter = !_.isEmpty(filter) && _.isString(filter) ? _.castArray(index.deserialize(filter)) : [];
|
|
1677
1697
|
query[_private.PVK].options.sort = _.isPlainObject(sort) && _.every(_.values(sort), _.isNumber) ? sort : undefined;
|
|
1678
1698
|
query[_private.PVK].options.includes = _.isArray(includes) && _.every(includes, _.isString) ? includes : undefined;
|