@hestia-earth/api 0.18.0 → 0.18.2

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.
@@ -144,7 +144,7 @@ export declare const isFolderUpload: (path: string) => boolean;
144
144
  export declare const isOwner: (file: Partial<File>, user: User) => boolean;
145
145
  export declare const isAuthorized: ({ authorizedUsers }: Partial<File>, user: User) => boolean;
146
146
  export declare const canRemove: (file: Partial<File>, user: User) => boolean;
147
- export declare const canValidate: ({ status, isPrivate, archived }: Partial<File>, { admin }: Partial<User>) => boolean;
147
+ export declare const canValidate: ({ status, isPrivate, archived }: Partial<File>, user: Partial<User>) => boolean;
148
148
  export declare const isValidated: ({ validatedAt, status }: Partial<File>) => boolean;
149
149
  export declare const canSubmit: (file: Partial<File>, user: User) => boolean;
150
150
  export declare const canFeedback: ({ status }: File) => boolean;
@@ -22,6 +22,7 @@ var __spreadArrays = (this && this.__spreadArrays) || function () {
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.isDraft = exports.canFeedback = exports.canSubmit = exports.isValidated = exports.canValidate = exports.canRemove = exports.isAuthorized = exports.isOwner = exports.isFolderUpload = exports.isAggregation = exports.aggregationFolder = exports.isGlossary = exports.glossaryFolder = exports.analysesFolder = exports.filenameFromPath = exports.rootFolderFromPath = exports.folderFromPath = exports.replaceInvalidChars = exports.validPathChars = exports.fileToExt = exports.filepathSearch = exports.filenameSearch = exports.File = exports.FilePipelineError = exports.FilePipelineProgress = exports.FilePipelineStatus = exports.FileError = exports.FileStatus = exports.FileProgress = exports.HestiaExtensions = exports.finalFormatExtensions = exports.SupportedExtensions = exports.sizeInMb = exports.MAX_SIZE_MB = exports.MAX_SIZE = exports.mb = void 0;
24
24
  var model_base_1 = require("../../db/model.base");
25
+ var model_1 = require("../../users/model/model");
25
26
  exports.mb = 1048576;
26
27
  exports.MAX_SIZE = 2;
27
28
  exports.MAX_SIZE_MB = 2 * exports.mb;
@@ -174,7 +175,7 @@ exports.isAuthorized = function (_a, user) {
174
175
  return (authorizedUsers || []).map(asString).includes(asString(user));
175
176
  };
176
177
  exports.canRemove = function (file, user) {
177
- return user.admin ||
178
+ return model_1.isAdmin(user) ||
178
179
  !exports.isValidated(file) ||
179
180
  file.isPrivate;
180
181
  };
@@ -183,10 +184,9 @@ var validateStatuses = [
183
184
  FileStatus.indexJsonDone,
184
185
  FileError.indexJsonError
185
186
  ];
186
- exports.canValidate = function (_a, _b) {
187
+ exports.canValidate = function (_a, user) {
187
188
  var status = _a.status, isPrivate = _a.isPrivate, archived = _a.archived;
188
- var admin = _b.admin;
189
- return !archived && validateStatuses.includes(status) && (isPrivate || admin);
189
+ return !archived && validateStatuses.includes(status) && (isPrivate || model_1.isReviewer(user));
190
190
  };
191
191
  exports.isValidated = function (_a) {
192
192
  var validatedAt = _a.validatedAt, status = _a.status;
@@ -8,6 +8,7 @@ export declare enum MaxUploads {
8
8
  export declare enum UserRole {
9
9
  Researcher = "default",
10
10
  Developer = "developer",
11
+ Reviewer = "reviewer",
11
12
  Admin = "admin"
12
13
  }
13
14
  export declare class User extends BaseModel {
@@ -42,6 +43,7 @@ export declare class User extends BaseModel {
42
43
  }
43
44
  export declare const name: ({ firstName, lastName }: Partial<User>) => string;
44
45
  export declare const isAdmin: ({ role }: Partial<User>) => boolean;
46
+ export declare const isReviewer: ({ role }: Partial<User>) => boolean;
45
47
  export declare const isDeveloper: ({ role }: Partial<User>) => boolean;
46
48
  export declare const contains: (users: Partial<User>[], user: Partial<User>) => boolean;
47
49
  export declare const actorId: (user: Partial<User>) => string;
@@ -24,7 +24,7 @@ var __assign = (this && this.__assign) || function () {
24
24
  return __assign.apply(this, arguments);
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.userToActor = exports.actorId = exports.contains = exports.isDeveloper = exports.isAdmin = exports.name = exports.User = exports.UserRole = exports.MaxUploads = exports.defaultMaxApiCalls = void 0;
27
+ exports.userToActor = exports.actorId = exports.contains = exports.isDeveloper = exports.isReviewer = exports.isAdmin = exports.name = exports.User = exports.UserRole = exports.MaxUploads = exports.defaultMaxApiCalls = void 0;
28
28
  var schema_1 = require("@hestia-earth/schema");
29
29
  var model_base_1 = require("../../db/model.base");
30
30
  exports.defaultMaxApiCalls = 100;
@@ -37,6 +37,7 @@ var UserRole;
37
37
  (function (UserRole) {
38
38
  UserRole["Researcher"] = "default";
39
39
  UserRole["Developer"] = "developer";
40
+ UserRole["Reviewer"] = "reviewer";
40
41
  UserRole["Admin"] = "admin";
41
42
  })(UserRole = exports.UserRole || (exports.UserRole = {}));
42
43
  var User = (function (_super) {
@@ -57,10 +58,18 @@ exports.isAdmin = function (_a) {
57
58
  var role = _a.role;
58
59
  return role === UserRole.Admin;
59
60
  };
61
+ exports.isReviewer = function (_a) {
62
+ var role = _a.role;
63
+ return [
64
+ UserRole.Reviewer,
65
+ UserRole.Admin
66
+ ].includes(role);
67
+ };
60
68
  exports.isDeveloper = function (_a) {
61
69
  var role = _a.role;
62
70
  return [
63
71
  UserRole.Developer,
72
+ UserRole.Reviewer,
64
73
  UserRole.Admin
65
74
  ].includes(role);
66
75
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/api",
3
- "version": "0.18.0",
3
+ "version": "0.18.2",
4
4
  "description": "Hestia API definitions",
5
5
  "main": "dist/models.js",
6
6
  "typings": "dist/models.d.ts",
@@ -36,7 +36,7 @@
36
36
  "@commitlint/cli": "^16.2.4",
37
37
  "@commitlint/config-conventional": "^16.2.4",
38
38
  "@elastic/elasticsearch": "7.13.0",
39
- "@hestia-earth/eslint-config": "^0.0.4",
39
+ "@hestia-earth/eslint-config": "^0.0.5",
40
40
  "@hestia-earth/json-schema": "^14.0.0",
41
41
  "@hestia-earth/schema-convert": "^14.0.0",
42
42
  "@hestia-earth/schema-validation": "^14.0.0",