proto.io 0.0.163 → 0.0.165
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/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 +2 -2
- package/dist/adapters/file/filesystem.js.map +1 -1
- package/dist/adapters/file/filesystem.mjs.map +1 -1
- package/dist/adapters/file/google-cloud-storage.d.ts +2 -2
- package/dist/adapters/file/google-cloud-storage.js.map +1 -1
- package/dist/adapters/file/google-cloud-storage.mjs.map +1 -1
- package/dist/adapters/storage/progres.d.ts +16 -13
- package/dist/adapters/storage/progres.js +138 -82
- package/dist/adapters/storage/progres.js.map +1 -1
- package/dist/adapters/storage/progres.mjs +140 -84
- package/dist/adapters/storage/progres.mjs.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.mjs +3 -3
- package/dist/index.d.ts +7 -12
- package/dist/index.js +24 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -27
- package/dist/index.mjs.map +1 -1
- package/dist/internals/{index-ByfpVHca.mjs → index-BYbMU-Ao.mjs} +2 -2
- package/dist/internals/{index-ByfpVHca.mjs.map → index-BYbMU-Ao.mjs.map} +1 -1
- package/dist/internals/{index-S5Bq-KsU.mjs → index-BejQNqvC.mjs} +2 -2
- package/dist/internals/{index-S5Bq-KsU.mjs.map → index-BejQNqvC.mjs.map} +1 -1
- package/dist/internals/{index-BoP4kl2R.mjs → index-BibByOcU.mjs} +2 -2
- package/dist/internals/{index-BoP4kl2R.mjs.map → index-BibByOcU.mjs.map} +1 -1
- package/dist/internals/index-BqFdBhFc.js.map +1 -1
- package/dist/internals/index-CSNRyhjB.js.map +1 -1
- package/dist/internals/index-CVutVPmd.js.map +1 -1
- package/dist/internals/{index-BeV63sFw.d.ts → index-DaDfXlay.d.ts} +2 -2
- package/dist/internals/index-DaDfXlay.d.ts.map +1 -0
- package/dist/internals/index-Dz3jvqxZ.js.map +1 -1
- package/dist/internals/{index-YdOGTHp1.d.ts → index-RPh4TX0T.d.ts} +3 -2
- package/dist/internals/index-RPh4TX0T.d.ts.map +1 -0
- package/dist/internals/{index-BsuUdR0W.d.ts → index-bCACA0cS.d.ts} +2 -2
- package/dist/internals/index-bCACA0cS.d.ts.map +1 -0
- package/dist/internals/index-be1VYBY2.mjs.map +1 -1
- package/dist/internals/{random-w8WDYQEe.mjs → random-B1P0EZO5.mjs} +5 -10
- package/dist/internals/random-B1P0EZO5.mjs.map +1 -0
- package/dist/internals/{random-uT4D0y_q.js → random-q0PeamQE.js} +3 -8
- package/dist/internals/random-q0PeamQE.js.map +1 -0
- package/package.json +20 -20
- package/dist/internals/index-BeV63sFw.d.ts.map +0 -1
- package/dist/internals/index-BsuUdR0W.d.ts.map +0 -1
- package/dist/internals/index-YdOGTHp1.d.ts.map +0 -1
- package/dist/internals/random-uT4D0y_q.js.map +0 -1
- package/dist/internals/random-w8WDYQEe.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-bCACA0cS.js';
|
|
2
|
+
export { c as classExtends, e as isFile, a as isObject, i as isQuery, d as isRole, b as isUser } from './internals/index-bCACA0cS.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-RPh4TX0T.js';
|
|
5
5
|
import '@o2ter/utils-js';
|
|
6
6
|
import 'socket.io-client';
|
|
7
7
|
import '@socket.io/component-emitter';
|
package/dist/client.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-BibByOcU.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-BibByOcU.mjs';
|
|
3
3
|
export { Decimal } from 'decimal.js';
|
|
4
|
-
import './internals/index-
|
|
4
|
+
import './internals/index-BYbMU-Ao.mjs';
|
|
5
5
|
import 'lodash';
|
|
6
6
|
import './internals/private-BUpLAMZi.mjs';
|
|
7
7
|
import '@o2ter/utils-js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as socket_io from 'socket.io';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export { D as DeserializeOptions, S as SerializeOptions, c as TFileStorage, d as TSerializable, e as deserialize, s as serialize } from './internals/index-YdOGTHp1.js';
|
|
2
|
+
import { Router } from 'express';
|
|
3
|
+
import { Server } from '@o2ter/server-js';
|
|
4
|
+
import { T as TSchema, _ as _TValue, P as ProtoService, a as ProtoServiceOptions, b as ProtoServiceKeyOptions } from './internals/index-RPh4TX0T.js';
|
|
5
|
+
export { D as DeserializeOptions, S as SerializeOptions, c as TFileStorage, d as TSerializable, e as deserialize, s as serialize } from './internals/index-RPh4TX0T.js';
|
|
7
6
|
import Decimal from 'decimal.js';
|
|
8
7
|
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-
|
|
8
|
+
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-bCACA0cS.js';
|
|
10
9
|
import '@o2ter/utils-js';
|
|
11
10
|
import 'jsonwebtoken';
|
|
12
11
|
import 'lodash';
|
|
@@ -62,14 +61,10 @@ declare const schema: ((x: Record<string, TSchema>) => Record<string, TSchema>)
|
|
|
62
61
|
readonly foreignField: string | undefined;
|
|
63
62
|
};
|
|
64
63
|
};
|
|
65
|
-
type AdapterHandler<E, Handler extends RequestHandler = RequestHandler> = Handler extends (req: infer Req, ...args: infer Rest) => void ? (req: ProtoService<E> & {
|
|
66
|
-
req: Req;
|
|
67
|
-
}, ...args: Rest) => void : never;
|
|
68
64
|
declare const ProtoRoute: <E>(options: {
|
|
69
|
-
adapters?: AdapterHandler<E>[];
|
|
70
65
|
proto: ProtoService<E> | (ProtoServiceOptions<E> & ProtoServiceKeyOptions);
|
|
71
|
-
}) => Promise<
|
|
72
|
-
declare const registerProtoSocket: <E>(proto: ProtoService<E>, server: Server, endpoint?: string) => socket_io.Server<
|
|
66
|
+
}) => Promise<Router>;
|
|
67
|
+
declare const registerProtoSocket: <E>(proto: ProtoService<E>, server: Server, endpoint?: string) => socket_io.Server<socket_io.DefaultEventsMap, socket_io.DefaultEventsMap, socket_io.DefaultEventsMap, any> | socket_io.Namespace<socket_io.DefaultEventsMap, socket_io.DefaultEventsMap, socket_io.DefaultEventsMap, any>;
|
|
73
68
|
|
|
74
69
|
export { ProtoRoute, ProtoService, ProtoRoute as default, registerProtoSocket, schema };
|
|
75
70
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ 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-q0PeamQE.js');
|
|
8
8
|
var _private = require('./internals/private-CSB1Ep4g.js');
|
|
9
9
|
var utilsJs = require('@o2ter/utils-js');
|
|
10
10
|
var index = require('./internals/index-Dz3jvqxZ.js');
|
|
@@ -783,8 +783,10 @@ const validateShapedObject = (schema, dataType) => {
|
|
|
783
783
|
}
|
|
784
784
|
};
|
|
785
785
|
const validateSchemaName = (schema) => {
|
|
786
|
-
|
|
787
|
-
|
|
786
|
+
for (const name of ['_Schema', '_Config']) {
|
|
787
|
+
if (!_.isNil(schema[name]))
|
|
788
|
+
throw Error('Reserved name of class');
|
|
789
|
+
}
|
|
788
790
|
for (const [, _schema] of _.toPairs(schema)) {
|
|
789
791
|
for (const [key] of _.toPairs(_schema.fields)) {
|
|
790
792
|
if (_.includes(index$1.TObject.defaultKeys, key))
|
|
@@ -1752,7 +1754,7 @@ var classesRoute = (router, proto) => {
|
|
|
1752
1754
|
const { name } = req.params;
|
|
1753
1755
|
const classes = proto.classes();
|
|
1754
1756
|
if (!_.includes(classes, name))
|
|
1755
|
-
return res.sendStatus(404);
|
|
1757
|
+
return void res.sendStatus(404);
|
|
1756
1758
|
await response(res, () => defaultHandler(req));
|
|
1757
1759
|
});
|
|
1758
1760
|
router.post('/relation', serverJs.Server.text({ type: '*/*' }), async (req, res) => {
|
|
@@ -1784,7 +1786,7 @@ var classesRoute = (router, proto) => {
|
|
|
1784
1786
|
const { name } = req.params;
|
|
1785
1787
|
const classes = proto.classes();
|
|
1786
1788
|
if (!_.includes(classes, name))
|
|
1787
|
-
return res.sendStatus(404);
|
|
1789
|
+
return void res.sendStatus(404);
|
|
1788
1790
|
const payload = proto.connect(req);
|
|
1789
1791
|
await response(res, async () => createQuery(payload, req, true).find({ master: payload.isMaster }));
|
|
1790
1792
|
});
|
|
@@ -1798,7 +1800,7 @@ var classesRoute = (router, proto) => {
|
|
|
1798
1800
|
const { name } = req.params;
|
|
1799
1801
|
const classes = proto.classes();
|
|
1800
1802
|
if (!_.includes(classes, name))
|
|
1801
|
-
return res.sendStatus(404);
|
|
1803
|
+
return void res.sendStatus(404);
|
|
1802
1804
|
const payload = proto.connect(req);
|
|
1803
1805
|
const { weight } = req.query;
|
|
1804
1806
|
if (_.isEmpty(weight) || !_.isString(weight))
|
|
@@ -1818,7 +1820,7 @@ var classesRoute = (router, proto) => {
|
|
|
1818
1820
|
const { name } = req.params;
|
|
1819
1821
|
const classes = proto.classes();
|
|
1820
1822
|
if (!_.includes(classes, name))
|
|
1821
|
-
return res.sendStatus(404);
|
|
1823
|
+
return void res.sendStatus(404);
|
|
1822
1824
|
const payload = proto.connect(req);
|
|
1823
1825
|
await response(res, async () => createQuery(payload, req, true).nonrefs({ master: payload.isMaster }));
|
|
1824
1826
|
});
|
|
@@ -1832,7 +1834,7 @@ var classesRoute = (router, proto) => {
|
|
|
1832
1834
|
const { name, id } = req.params;
|
|
1833
1835
|
const classes = proto.classes();
|
|
1834
1836
|
if (!_.includes(classes, name))
|
|
1835
|
-
return res.sendStatus(404);
|
|
1837
|
+
return void res.sendStatus(404);
|
|
1836
1838
|
const payload = proto.connect(req);
|
|
1837
1839
|
await response(res, () => payload.Query(name).get(id, { master: payload.isMaster }));
|
|
1838
1840
|
});
|
|
@@ -1841,7 +1843,7 @@ var classesRoute = (router, proto) => {
|
|
|
1841
1843
|
const { name, id } = req.params;
|
|
1842
1844
|
const classes = proto.classes();
|
|
1843
1845
|
if (!_.includes(classes, name))
|
|
1844
|
-
return res.sendStatus(404);
|
|
1846
|
+
return void res.sendStatus(404);
|
|
1845
1847
|
const payload = proto.connect(req);
|
|
1846
1848
|
await response(res, async () => payload.refs(payload.Object(name, id), { master: payload.isMaster }));
|
|
1847
1849
|
});
|
|
@@ -1850,7 +1852,7 @@ var classesRoute = (router, proto) => {
|
|
|
1850
1852
|
const { name, id } = req.params;
|
|
1851
1853
|
const classes = proto.classes();
|
|
1852
1854
|
if (!_.includes(classes, name))
|
|
1853
|
-
return res.sendStatus(404);
|
|
1855
|
+
return void res.sendStatus(404);
|
|
1854
1856
|
const payload = proto.connect(req);
|
|
1855
1857
|
const query = payload.Query(name).equalTo('_id', id);
|
|
1856
1858
|
const update = _.mapValues(index.deserialize(req.body), v => ({ $set: v }));
|
|
@@ -1859,29 +1861,29 @@ var classesRoute = (router, proto) => {
|
|
|
1859
1861
|
router.delete('/classes/:name', serverJs.Server.text({ type: '*/*' }), async (req, res) => {
|
|
1860
1862
|
res.setHeader('Cache-Control', ['no-cache', 'no-store']);
|
|
1861
1863
|
if (!_.isEmpty(req.body))
|
|
1862
|
-
return res.sendStatus(400);
|
|
1864
|
+
return void res.sendStatus(400);
|
|
1863
1865
|
const { name } = req.params;
|
|
1864
1866
|
const classes = proto.classes();
|
|
1865
1867
|
if (!_.includes(classes, name))
|
|
1866
|
-
return res.sendStatus(404);
|
|
1868
|
+
return void res.sendStatus(404);
|
|
1867
1869
|
const payload = proto.connect(req);
|
|
1868
1870
|
await response(res, () => createQuery(payload, req, false).deleteMany({ master: payload.isMaster }));
|
|
1869
1871
|
});
|
|
1870
1872
|
router.delete('/relation', serverJs.Server.text({ type: '*/*' }), async (req, res) => {
|
|
1871
1873
|
res.setHeader('Cache-Control', ['no-cache', 'no-store']);
|
|
1872
1874
|
if (!_.isEmpty(req.body))
|
|
1873
|
-
return res.sendStatus(400);
|
|
1875
|
+
return void res.sendStatus(400);
|
|
1874
1876
|
const payload = proto.connect(req);
|
|
1875
1877
|
await response(res, () => createQuery(payload, req, false).deleteMany({ master: payload.isMaster }));
|
|
1876
1878
|
});
|
|
1877
1879
|
router.delete('/classes/:name/:id', serverJs.Server.text({ type: '*/*' }), async (req, res) => {
|
|
1878
1880
|
res.setHeader('Cache-Control', ['no-cache', 'no-store']);
|
|
1879
1881
|
if (!_.isEmpty(req.body))
|
|
1880
|
-
return res.sendStatus(400);
|
|
1882
|
+
return void res.sendStatus(400);
|
|
1881
1883
|
const { name, id } = req.params;
|
|
1882
1884
|
const classes = proto.classes();
|
|
1883
1885
|
if (!_.includes(classes, name))
|
|
1884
|
-
return res.sendStatus(404);
|
|
1886
|
+
return void res.sendStatus(404);
|
|
1885
1887
|
const payload = proto.connect(req);
|
|
1886
1888
|
const query = payload.Query(name).equalTo('_id', id);
|
|
1887
1889
|
await response(res, () => query.deleteOne({ master: payload.isMaster }));
|
|
@@ -1918,7 +1920,7 @@ var functionRoute = (router, proto) => {
|
|
|
1918
1920
|
res.setHeader('Cache-Control', ['no-cache', 'no-store']);
|
|
1919
1921
|
const { name } = req.params;
|
|
1920
1922
|
if (_.isNil(proto[_private.PVK].functions[name]))
|
|
1921
|
-
return res.sendStatus(404);
|
|
1923
|
+
return void res.sendStatus(404);
|
|
1922
1924
|
await response(res, () => {
|
|
1923
1925
|
const payload = proto.connect(req, x => ({
|
|
1924
1926
|
params: null,
|
|
@@ -1930,7 +1932,7 @@ var functionRoute = (router, proto) => {
|
|
|
1930
1932
|
res.setHeader('Cache-Control', ['no-cache', 'no-store']);
|
|
1931
1933
|
const { name } = req.params;
|
|
1932
1934
|
if (_.isNil(proto[_private.PVK].functions[name]))
|
|
1933
|
-
return res.sendStatus(404);
|
|
1935
|
+
return void res.sendStatus(404);
|
|
1934
1936
|
await response(res, () => {
|
|
1935
1937
|
const payload = proto.connect(req, x => ({
|
|
1936
1938
|
params: x.rebind(index.deserialize(req.body, { objAttrs: index$1.TObject.defaultReadonlyKeys })),
|
|
@@ -1992,9 +1994,9 @@ var filesRoute = (router, proto) => {
|
|
|
1992
1994
|
const query = payload.Query('File').equalTo('_id', id);
|
|
1993
1995
|
const file = await query.first({ master: payload.isMaster });
|
|
1994
1996
|
if (!file || file.filename !== name)
|
|
1995
|
-
return res.sendStatus(404);
|
|
1997
|
+
return void res.sendStatus(404);
|
|
1996
1998
|
if (_.isNil(file.token) || _.isNil(file.size) || _.isNil(file.type))
|
|
1997
|
-
return res.sendStatus(404);
|
|
1999
|
+
return void res.sendStatus(404);
|
|
1998
2000
|
const ranges = req.range(file.size);
|
|
1999
2001
|
const match = req.headers['if-none-match'];
|
|
2000
2002
|
if (match === `"${id}"`) {
|
|
@@ -2149,7 +2151,7 @@ var schemaRoute = (router, proto) => {
|
|
|
2149
2151
|
res.setHeader('Cache-Control', ['no-cache', 'no-store']);
|
|
2150
2152
|
const { name } = req.params;
|
|
2151
2153
|
if (_.isNil(proto.schema[name]))
|
|
2152
|
-
return res.sendStatus(404);
|
|
2154
|
+
return void res.sendStatus(404);
|
|
2153
2155
|
const payload = proto.connect(req);
|
|
2154
2156
|
await response(res, () => {
|
|
2155
2157
|
if (!payload.isMaster)
|
|
@@ -2250,10 +2252,9 @@ const schema = _.assign((x) => x, {
|
|
|
2250
2252
|
relation: (target, foreignField) => ({ type: 'relation', target, foreignField }),
|
|
2251
2253
|
});
|
|
2252
2254
|
const ProtoRoute = async (options) => {
|
|
2253
|
-
const
|
|
2254
|
-
const proto = _proto instanceof ProtoService ? _proto : new ProtoService(_proto);
|
|
2255
|
+
const proto = options.proto instanceof ProtoService ? options.proto : new ProtoService(options.proto);
|
|
2255
2256
|
await proto[_private.PVK].prepare();
|
|
2256
|
-
const router = serverJs.Server.Router().use(authHandler(proto),
|
|
2257
|
+
const router = serverJs.Server.Router().use(authHandler(proto), (req, res, next) => {
|
|
2257
2258
|
const payload = proto.connect(req);
|
|
2258
2259
|
if (!payload.isInvalidMasterToken)
|
|
2259
2260
|
return next();
|