proto.io 0.0.195 → 0.0.197
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/index.js +10 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -669,12 +669,8 @@ const proxy = (x) => {
|
|
|
669
669
|
for (const name of _.uniq(_.flatMap(utilsJs.prototypes(proxy), x => Object.getOwnPropertyNames(x)))) {
|
|
670
670
|
if (name === 'constructor')
|
|
671
671
|
continue;
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
}
|
|
675
|
-
else {
|
|
676
|
-
Object.defineProperty(proxy, name, { get: () => self[name] });
|
|
677
|
-
}
|
|
672
|
+
const value = _.isFunction(self[name]) ? self[name].bind(self) : self[name];
|
|
673
|
+
Object.defineProperty(proxy, name, { get: () => value });
|
|
678
674
|
}
|
|
679
675
|
return proxy;
|
|
680
676
|
};
|
|
@@ -1292,8 +1288,14 @@ const sessionId = (proto, request) => {
|
|
|
1292
1288
|
};
|
|
1293
1289
|
const userCacheMap = new WeakMap;
|
|
1294
1290
|
const fetchSessionInfo = async (proto, userId) => {
|
|
1295
|
-
if (!userId)
|
|
1296
|
-
|
|
1291
|
+
if (!userId) {
|
|
1292
|
+
const user = proto.req ? await proto[_private.PVK].options.userResolver(proto, undefined) : undefined;
|
|
1293
|
+
const _roles = user instanceof index.TUser ? _.filter(await proto.userRoles(user), x => !_.isEmpty(x.name)) : [];
|
|
1294
|
+
return {
|
|
1295
|
+
user: user?.clone(),
|
|
1296
|
+
_roles: _.map(_roles, x => x.clone()),
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1297
1299
|
if (!userCacheMap.has(proto[_private.PVK]))
|
|
1298
1300
|
userCacheMap.set(proto[_private.PVK], {});
|
|
1299
1301
|
const cache = userCacheMap.get(proto[_private.PVK]);
|
|
@@ -2054,18 +2056,6 @@ var classesRoute = (router, proto) => {
|
|
|
2054
2056
|
// THE SOFTWARE.
|
|
2055
2057
|
//
|
|
2056
2058
|
var functionRoute = (router, proto) => {
|
|
2057
|
-
router.get('/functions/:name', async (req, res) => {
|
|
2058
|
-
res.setHeader('Cache-Control', ['no-cache', 'no-store']);
|
|
2059
|
-
const { name } = req.params;
|
|
2060
|
-
if (_.isNil(proto[_private.PVK].functions[name]))
|
|
2061
|
-
return void res.sendStatus(404);
|
|
2062
|
-
await response(res, () => {
|
|
2063
|
-
const payload = proto.connect(req, x => ({
|
|
2064
|
-
params: null,
|
|
2065
|
-
}));
|
|
2066
|
-
return payload[_private.PVK].run(payload, name, payload, { master: payload.isMaster });
|
|
2067
|
-
});
|
|
2068
|
-
});
|
|
2069
2059
|
router.post('/functions/:name', serverJs.Server.text({ type: '*/*' }), async (req, res) => {
|
|
2070
2060
|
res.setHeader('Cache-Control', ['no-cache', 'no-store']);
|
|
2071
2061
|
const { name } = req.params;
|
|
@@ -2106,16 +2096,6 @@ var functionRoute = (router, proto) => {
|
|
|
2106
2096
|
// THE SOFTWARE.
|
|
2107
2097
|
//
|
|
2108
2098
|
var jobRoute = (router, proto) => {
|
|
2109
|
-
router.get('/jobs/:name', async (req, res) => {
|
|
2110
|
-
res.setHeader('Cache-Control', ['no-cache', 'no-store']);
|
|
2111
|
-
const { name } = req.params;
|
|
2112
|
-
if (_.isNil(proto[_private.PVK].jobs[name]))
|
|
2113
|
-
return void res.sendStatus(404);
|
|
2114
|
-
await response(res, () => {
|
|
2115
|
-
const payload = proto.connect(req);
|
|
2116
|
-
return payload[_private.PVK].scheduleJob(payload, name, null, { master: payload.isMaster });
|
|
2117
|
-
});
|
|
2118
|
-
});
|
|
2119
2099
|
router.post('/jobs/:name', serverJs.Server.text({ type: '*/*' }), async (req, res) => {
|
|
2120
2100
|
res.setHeader('Cache-Control', ['no-cache', 'no-store']);
|
|
2121
2101
|
const { name } = req.params;
|