@hestia-earth/api 0.10.0 → 0.10.1-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.
|
@@ -71,6 +71,7 @@ export declare class File extends BaseModel {
|
|
|
71
71
|
filepath: string;
|
|
72
72
|
folder?: string;
|
|
73
73
|
user: User;
|
|
74
|
+
authorizedUsers?: User[];
|
|
74
75
|
contentType?: string;
|
|
75
76
|
archived: boolean;
|
|
76
77
|
status?: status;
|
|
@@ -88,6 +89,7 @@ export declare class File extends BaseModel {
|
|
|
88
89
|
skipValidation?: boolean;
|
|
89
90
|
study?: File;
|
|
90
91
|
readonly isOwner?: boolean;
|
|
92
|
+
readonly isAuthorized?: boolean;
|
|
91
93
|
readonly isValidated?: boolean;
|
|
92
94
|
readonly isDraft?: boolean;
|
|
93
95
|
readonly originalPath?: string;
|
|
@@ -121,5 +123,8 @@ export declare const isGlossary: (path: string) => boolean;
|
|
|
121
123
|
export declare const aggregationFolder = "aggregation";
|
|
122
124
|
export declare const isAggregation: (path: string) => boolean;
|
|
123
125
|
export declare const isFolderUpload: (path: string) => boolean;
|
|
126
|
+
export declare const canValidate: ({ status, isPrivate }: Partial<File>, { admin }: Partial<User>) => boolean;
|
|
124
127
|
export declare const isValidated: ({ validatedAt, status }: Partial<File>) => boolean;
|
|
128
|
+
export declare const canSubmit: ({ status, userValidatedAt, isOwner, isAuthorized }: Partial<File>) => boolean;
|
|
125
129
|
export declare const isDraft: ({ filepath, filename }: Partial<File>) => boolean;
|
|
130
|
+
export declare const isAuthorized: ({ authorizedUsers }: Partial<File>, user: any) => boolean;
|
|
@@ -20,7 +20,7 @@ var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
|
20
20
|
return r;
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.isDraft = exports.isValidated = exports.isFolderUpload = exports.isAggregation = exports.aggregationFolder = exports.isGlossary = exports.glossaryFolder = 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.SupportedExtensions = exports.sizeInMb = exports.MAX_SIZE_MB = exports.MAX_SIZE = exports.mb = void 0;
|
|
23
|
+
exports.isAuthorized = exports.isDraft = exports.canSubmit = exports.isValidated = exports.canValidate = exports.isFolderUpload = exports.isAggregation = exports.aggregationFolder = exports.isGlossary = exports.glossaryFolder = 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.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
25
|
exports.mb = 1048576;
|
|
26
26
|
exports.MAX_SIZE = 2;
|
|
@@ -153,6 +153,16 @@ exports.isFolderUpload = function (path) { return [
|
|
|
153
153
|
exports.isAggregation,
|
|
154
154
|
exports.isGlossary
|
|
155
155
|
].some(function (f) { return f(path); }); };
|
|
156
|
+
var validateStatuses = [
|
|
157
|
+
FileStatus.validateDataDone,
|
|
158
|
+
FileStatus.indexJsonDone,
|
|
159
|
+
FileError.indexJsonError
|
|
160
|
+
];
|
|
161
|
+
exports.canValidate = function (_a, _b) {
|
|
162
|
+
var status = _a.status, isPrivate = _a.isPrivate;
|
|
163
|
+
var admin = _b.admin;
|
|
164
|
+
return validateStatuses.includes(status) && (admin || isPrivate);
|
|
165
|
+
};
|
|
156
166
|
exports.isValidated = function (_a) {
|
|
157
167
|
var validatedAt = _a.validatedAt, status = _a.status;
|
|
158
168
|
return !!validatedAt ||
|
|
@@ -161,7 +171,19 @@ exports.isValidated = function (_a) {
|
|
|
161
171
|
FileStatus.copyHestiaDone
|
|
162
172
|
].includes(status);
|
|
163
173
|
};
|
|
174
|
+
var submitStatuses = [
|
|
175
|
+
FileStatus.validateDataDone
|
|
176
|
+
];
|
|
177
|
+
exports.canSubmit = function (_a) {
|
|
178
|
+
var status = _a.status, userValidatedAt = _a.userValidatedAt, isOwner = _a.isOwner, isAuthorized = _a.isAuthorized;
|
|
179
|
+
return submitStatuses.includes(status) && !userValidatedAt && (isOwner || isAuthorized);
|
|
180
|
+
};
|
|
164
181
|
exports.isDraft = function (_a) {
|
|
165
182
|
var filepath = _a.filepath, filename = _a.filename;
|
|
166
183
|
return (filepath || filename || '').endsWith(SupportedExtensions.draft);
|
|
167
184
|
};
|
|
185
|
+
var asString = function (v) { return typeof v === 'object' && v._id ? v._id.toString() : v.toString(); };
|
|
186
|
+
exports.isAuthorized = function (_a, user) {
|
|
187
|
+
var authorizedUsers = _a.authorizedUsers;
|
|
188
|
+
return (authorizedUsers || []).map(asString).includes(asString(user));
|
|
189
|
+
};
|