proto.io 0.0.145 → 0.0.147

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.
Files changed (42) hide show
  1. package/dist/adapters/file/database.d.ts +3 -3
  2. package/dist/adapters/file/database.js +1 -1
  3. package/dist/adapters/file/database.js.map +1 -1
  4. package/dist/adapters/file/database.mjs +1 -1
  5. package/dist/adapters/file/database.mjs.map +1 -1
  6. package/dist/adapters/file/filesystem.d.ts +3 -3
  7. package/dist/adapters/file/filesystem.js +1 -1
  8. package/dist/adapters/file/filesystem.js.map +1 -1
  9. package/dist/adapters/file/filesystem.mjs +1 -1
  10. package/dist/adapters/file/filesystem.mjs.map +1 -1
  11. package/dist/adapters/file/google-cloud-storage.d.ts +3 -3
  12. package/dist/adapters/file/google-cloud-storage.js +1 -1
  13. package/dist/adapters/file/google-cloud-storage.js.map +1 -1
  14. package/dist/adapters/file/google-cloud-storage.mjs +1 -1
  15. package/dist/adapters/file/google-cloud-storage.mjs.map +1 -1
  16. package/dist/adapters/storage/progres.d.ts +1 -1
  17. package/dist/client.d.ts +3 -3
  18. package/dist/client.js +1 -1
  19. package/dist/client.mjs +2 -2
  20. package/dist/index.d.ts +3 -3
  21. package/dist/index.js +19 -17
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +20 -18
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/internals/{index-i4lOAqi2.d.ts → index-BDB4idmt.d.ts} +3 -3
  26. package/dist/internals/index-BDB4idmt.d.ts.map +1 -0
  27. package/dist/internals/{index-DW9_3n_K.d.ts → index-BWztjrw_.d.ts} +4 -4
  28. package/dist/internals/index-BWztjrw_.d.ts.map +1 -0
  29. package/dist/internals/index-BqFdBhFc.js.map +1 -1
  30. package/dist/internals/index-C6zdNpc_.js.map +1 -1
  31. package/dist/internals/{index-D5nf79vF.js → index-CT01T3qs.js} +13 -13
  32. package/dist/internals/{index-D5nf79vF.js.map → index-CT01T3qs.js.map} +1 -1
  33. package/dist/internals/{index-ZIegYNKT.mjs → index-Do-zNOpD.mjs} +13 -13
  34. package/dist/internals/{index-ZIegYNKT.mjs.map → index-Do-zNOpD.mjs.map} +1 -1
  35. package/dist/internals/index-EOtjV6U_.mjs.map +1 -1
  36. package/dist/internals/{index-DWyLziGT.d.ts → index-bbPCIbir.d.ts} +3 -3
  37. package/dist/internals/index-bbPCIbir.d.ts.map +1 -0
  38. package/dist/internals/index-be1VYBY2.mjs.map +1 -1
  39. package/package.json +1 -1
  40. package/dist/internals/index-DW9_3n_K.d.ts.map +0 -1
  41. package/dist/internals/index-DWyLziGT.d.ts.map +0 -1
  42. package/dist/internals/index-i4lOAqi2.d.ts.map +0 -1
package/dist/index.mjs CHANGED
@@ -3,8 +3,8 @@ import { Server } from '@o2ter/server-js';
3
3
  import { Q as QueryValidator, g as generateId } from './internals/random-BjV_01xP.mjs';
4
4
  import { P as PVK } from './internals/private-BUpLAMZi.mjs';
5
5
  import { asyncStream, asyncIterableToArray, isBinaryData, base64ToBuffer } from '@o2ter/utils-js';
6
- import { T as TQuery, M as MASTER_USER_HEADER_NAME, a as MASTER_PASS_HEADER_NAME, A as AUTH_COOKIE_KEY, b as TUser, P as ProtoType, s as serialize, d as deserialize, U as UPLOAD_TOKEN_HEADER_NAME } from './internals/index-ZIegYNKT.mjs';
7
- export { c as ProtoClient, e as classExtends, j as isFile, f as isObject, i as isQuery, h as isRole, g as isUser } from './internals/index-ZIegYNKT.mjs';
6
+ import { T as TQuery, M as MASTER_USER_HEADER_NAME, a as MASTER_PASS_HEADER_NAME, A as AUTH_COOKIE_KEY, b as TUser, P as ProtoType, s as serialize, d as deserialize, U as UPLOAD_TOKEN_HEADER_NAME } from './internals/index-Do-zNOpD.mjs';
7
+ export { c as ProtoClient, e as classExtends, j as isFile, f as isObject, i as isQuery, h as isRole, g as isUser } from './internals/index-Do-zNOpD.mjs';
8
8
  import { d as decodeUpdateOp, T as TObject, i as isShape, a as isPointer, b as isRelation, c as defaultObjectKeyTypes, e as isPrimitive } from './internals/index-EOtjV6U_.mjs';
9
9
  import jwt from 'jsonwebtoken';
10
10
  import { Blob } from 'node:buffer';
@@ -797,14 +797,16 @@ class ProtoInternal {
797
797
  return func(proxy(payload ?? proto));
798
798
  const { callback, validator } = func;
799
799
  const roles = await proto.currentRoles();
800
- if (!!validator?.requireUser && !(await proto.currentUser()))
801
- throw Error('No permission');
802
- if (!!validator?.requireMaster && !options?.master)
803
- throw Error('No permission');
804
- if (_.isArray(validator?.requireAnyUserRoles) && !_.some(validator?.requireAnyUserRoles, x => _.includes(roles, x)))
805
- throw Error('No permission');
806
- if (_.isArray(validator?.requireAllUserRoles) && _.some(validator?.requireAllUserRoles, x => !_.includes(roles, x)))
807
- throw Error('No permission');
800
+ if (!options?.master) {
801
+ if (!!validator?.requireUser && !(await proto.currentUser()))
802
+ throw Error('No permission');
803
+ if (!!validator?.requireMaster)
804
+ throw Error('No permission');
805
+ if (_.isArray(validator?.requireAnyUserRoles) && !_.some(validator?.requireAnyUserRoles, x => _.includes(roles, x)))
806
+ throw Error('No permission');
807
+ if (_.isArray(validator?.requireAllUserRoles) && _.some(validator?.requireAllUserRoles, x => !_.includes(roles, x)))
808
+ throw Error('No permission');
809
+ }
808
810
  return callback(proxy(payload ?? proto));
809
811
  }
810
812
  async varifyPassword(proto, user, password, options) {
@@ -918,7 +920,7 @@ class ProtoInternal {
918
920
  return object;
919
921
  }
920
922
  catch (e) {
921
- this.destoryFileData(proto, file._id);
923
+ this.destroyFileData(proto, file._id);
922
924
  throw e;
923
925
  }
924
926
  }
@@ -956,7 +958,7 @@ class ProtoInternal {
956
958
  object[PVK].mutated = {};
957
959
  object[PVK].extra = {};
958
960
  }
959
- this.destoryFileData(proto, object.token);
961
+ this.destroyFileData(proto, object.token);
960
962
  if (_.isFunction(afterDelete)) {
961
963
  await afterDelete(proxy(Object.setPrototypeOf({ object, context }, proto)));
962
964
  }
@@ -972,10 +974,10 @@ class ProtoInternal {
972
974
  }
973
975
  });
974
976
  }
975
- destoryFileData(proto, id) {
977
+ destroyFileData(proto, id) {
976
978
  (async () => {
977
979
  try {
978
- await proto.fileStorage.destory(proto, id);
980
+ await proto.fileStorage.destroy(proto, id);
979
981
  }
980
982
  catch (e) {
981
983
  console.error(e);
@@ -1199,7 +1201,7 @@ const scheduleOp = {
1199
1201
  for await (const item of found) {
1200
1202
  const token = item.get('token');
1201
1203
  if (!_.isEmpty(token))
1202
- await proto.fileStorage.destory(proto, token);
1204
+ await proto.fileStorage.destroy(proto, token);
1203
1205
  }
1204
1206
  }
1205
1207
  await proto.storage.deleteMany({
@@ -1233,7 +1235,7 @@ const schedule = (proto) => {
1233
1235
  const schedule = setInterval(execute, 60 * 1000);
1234
1236
  return {
1235
1237
  execute,
1236
- destory() { clearInterval(schedule); }
1238
+ destroy() { clearInterval(schedule); }
1237
1239
  };
1238
1240
  };
1239
1241
 
@@ -1295,7 +1297,7 @@ class ProtoService extends ProtoType {
1295
1297
  });
1296
1298
  }
1297
1299
  async shutdown() {
1298
- this._schedule.destory();
1300
+ this._schedule.destroy();
1299
1301
  }
1300
1302
  classes() {
1301
1303
  return _.keys(this[PVK].options.schema);
@@ -1826,7 +1828,7 @@ var filesRoute = (router, proto) => {
1826
1828
  }
1827
1829
  catch (e) {
1828
1830
  if (file?._id)
1829
- proto[PVK].destoryFileData(proto, file._id);
1831
+ proto[PVK].destroyFileData(proto, file._id);
1830
1832
  throw e;
1831
1833
  }
1832
1834
  });