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.mjs
CHANGED
|
@@ -666,12 +666,8 @@ const proxy = (x) => {
|
|
|
666
666
|
for (const name of _.uniq(_.flatMap(prototypes(proxy), x => Object.getOwnPropertyNames(x)))) {
|
|
667
667
|
if (name === 'constructor')
|
|
668
668
|
continue;
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
}
|
|
672
|
-
else {
|
|
673
|
-
Object.defineProperty(proxy, name, { get: () => self[name] });
|
|
674
|
-
}
|
|
669
|
+
const value = _.isFunction(self[name]) ? self[name].bind(self) : self[name];
|
|
670
|
+
Object.defineProperty(proxy, name, { get: () => value });
|
|
675
671
|
}
|
|
676
672
|
return proxy;
|
|
677
673
|
};
|
|
@@ -1289,8 +1285,14 @@ const sessionId = (proto, request) => {
|
|
|
1289
1285
|
};
|
|
1290
1286
|
const userCacheMap = new WeakMap;
|
|
1291
1287
|
const fetchSessionInfo = async (proto, userId) => {
|
|
1292
|
-
if (!userId)
|
|
1293
|
-
|
|
1288
|
+
if (!userId) {
|
|
1289
|
+
const user = proto.req ? await proto[PVK].options.userResolver(proto, undefined) : undefined;
|
|
1290
|
+
const _roles = user instanceof TUser ? _.filter(await proto.userRoles(user), x => !_.isEmpty(x.name)) : [];
|
|
1291
|
+
return {
|
|
1292
|
+
user: user?.clone(),
|
|
1293
|
+
_roles: _.map(_roles, x => x.clone()),
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1294
1296
|
if (!userCacheMap.has(proto[PVK]))
|
|
1295
1297
|
userCacheMap.set(proto[PVK], {});
|
|
1296
1298
|
const cache = userCacheMap.get(proto[PVK]);
|
|
@@ -2051,18 +2053,6 @@ var classesRoute = (router, proto) => {
|
|
|
2051
2053
|
// THE SOFTWARE.
|
|
2052
2054
|
//
|
|
2053
2055
|
var functionRoute = (router, proto) => {
|
|
2054
|
-
router.get('/functions/:name', async (req, res) => {
|
|
2055
|
-
res.setHeader('Cache-Control', ['no-cache', 'no-store']);
|
|
2056
|
-
const { name } = req.params;
|
|
2057
|
-
if (_.isNil(proto[PVK].functions[name]))
|
|
2058
|
-
return void res.sendStatus(404);
|
|
2059
|
-
await response(res, () => {
|
|
2060
|
-
const payload = proto.connect(req, x => ({
|
|
2061
|
-
params: null,
|
|
2062
|
-
}));
|
|
2063
|
-
return payload[PVK].run(payload, name, payload, { master: payload.isMaster });
|
|
2064
|
-
});
|
|
2065
|
-
});
|
|
2066
2056
|
router.post('/functions/:name', Server.text({ type: '*/*' }), async (req, res) => {
|
|
2067
2057
|
res.setHeader('Cache-Control', ['no-cache', 'no-store']);
|
|
2068
2058
|
const { name } = req.params;
|
|
@@ -2103,16 +2093,6 @@ var functionRoute = (router, proto) => {
|
|
|
2103
2093
|
// THE SOFTWARE.
|
|
2104
2094
|
//
|
|
2105
2095
|
var jobRoute = (router, proto) => {
|
|
2106
|
-
router.get('/jobs/:name', async (req, res) => {
|
|
2107
|
-
res.setHeader('Cache-Control', ['no-cache', 'no-store']);
|
|
2108
|
-
const { name } = req.params;
|
|
2109
|
-
if (_.isNil(proto[PVK].jobs[name]))
|
|
2110
|
-
return void res.sendStatus(404);
|
|
2111
|
-
await response(res, () => {
|
|
2112
|
-
const payload = proto.connect(req);
|
|
2113
|
-
return payload[PVK].scheduleJob(payload, name, null, { master: payload.isMaster });
|
|
2114
|
-
});
|
|
2115
|
-
});
|
|
2116
2096
|
router.post('/jobs/:name', Server.text({ type: '*/*' }), async (req, res) => {
|
|
2117
2097
|
res.setHeader('Cache-Control', ['no-cache', 'no-store']);
|
|
2118
2098
|
const { name } = req.params;
|