proto.io 0.0.149 → 0.0.151

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.mjs CHANGED
@@ -143,7 +143,7 @@ const dispatcher = (proto, options, disableSecurity) => {
143
143
  includes: _includes,
144
144
  matches: _matches,
145
145
  objectIdSize: proto[PVK].options.objectIdSize
146
- }, _attrs), { lockTable: options.className });
146
+ }, _attrs), { lockTable: options.className, retry: true });
147
147
  }
148
148
  catch (e) {
149
149
  if (proto.storage.isDuplicateIdError(e))
@@ -167,7 +167,7 @@ const dispatcher = (proto, options, disableSecurity) => {
167
167
  includes: _includes,
168
168
  matches: _matches,
169
169
  objectIdSize: proto[PVK].options.objectIdSize
170
- }, _attrs), { lockTable: options.className });
170
+ }, _attrs), { lockTable: options.className, retry: true });
171
171
  }
172
172
  catch (e) {
173
173
  if (proto.storage.isDuplicateIdError(e))
@@ -193,7 +193,7 @@ const dispatcher = (proto, options, disableSecurity) => {
193
193
  const _setOnInsert = normalize(_validator.validateFields(query.className, setOnInsert, 'create', QueryValidator.patterns.name));
194
194
  while (true) {
195
195
  try {
196
- return await proto.storage.atomic((storage) => storage.upsertOne(_query, _update, _setOnInsert));
196
+ return await proto.storage.atomic((storage) => storage.upsertOne(_query, _update, _setOnInsert), { lockTable: query.className, retry: true });
197
197
  }
198
198
  catch (e) {
199
199
  if (proto.storage.isDuplicateIdError(e))
@@ -1144,9 +1144,9 @@ const sessionId = (proto, request) => {
1144
1144
  const sessionInfoMap = new WeakMap();
1145
1145
  const fetchSessionInfo = async (proto, userId) => {
1146
1146
  const user = _.isString(userId) ? await proto.Query('User').get(userId, { master: true }) : undefined;
1147
- const roles = user instanceof TUser ? _.compact(_.map(await proto.userRoles(user), x => x.name)) : [];
1147
+ const roles = user instanceof TUser ? _.filter(await proto.userRoles(user), x => !_.isEmpty(x.name)) : [];
1148
1148
  return {
1149
- roles: roles,
1149
+ _roles: roles,
1150
1150
  user: user instanceof TUser ? user : undefined,
1151
1151
  };
1152
1152
  };
@@ -1343,9 +1343,13 @@ class ProtoService extends ProtoType {
1343
1343
  const session = await this.sessionInfo();
1344
1344
  return session?.user;
1345
1345
  }
1346
- async currentRoles() {
1346
+ async _currentRoles() {
1347
1347
  const session = await this.sessionInfo();
1348
- return session?.roles ?? [];
1348
+ return session?._roles ?? [];
1349
+ }
1350
+ async currentRoles() {
1351
+ const roles = await this._currentRoles();
1352
+ return _.compact(_.map(roles, x => x.name));
1349
1353
  }
1350
1354
  get isMaster() {
1351
1355
  return this.req ? sessionIsMaster(this, this.req) === 'valid' : false;