@hestia-earth/api 0.10.1 → 0.11.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.
|
@@ -66,6 +66,12 @@ export declare enum FilePipelineError {
|
|
|
66
66
|
calculationEngineError = "calculationEngineError"
|
|
67
67
|
}
|
|
68
68
|
export declare type pipelineStatus = FilePipelineStatus | FilePipelineProgress | FilePipelineError;
|
|
69
|
+
export interface IFileComment {
|
|
70
|
+
content: string;
|
|
71
|
+
date: Date;
|
|
72
|
+
user: User;
|
|
73
|
+
readonly isOwner?: boolean;
|
|
74
|
+
}
|
|
69
75
|
export declare class File extends BaseModel {
|
|
70
76
|
filename: string;
|
|
71
77
|
filepath: string;
|
|
@@ -81,7 +87,7 @@ export declare class File extends BaseModel {
|
|
|
81
87
|
schemaVersion?: string;
|
|
82
88
|
schemaOutdated?: boolean;
|
|
83
89
|
glossaryOutdated?: boolean;
|
|
84
|
-
|
|
90
|
+
comments?: IFileComment[];
|
|
85
91
|
metadata?: {
|
|
86
92
|
slackThreadTs?: string;
|
|
87
93
|
};
|
|
@@ -125,7 +131,9 @@ export declare const isAggregation: (path: string) => boolean;
|
|
|
125
131
|
export declare const isFolderUpload: (path: string) => boolean;
|
|
126
132
|
export declare const isOwner: (file: Partial<File>, user: User) => boolean;
|
|
127
133
|
export declare const isAuthorized: ({ authorizedUsers }: Partial<File>, user: User) => boolean;
|
|
134
|
+
export declare const canRemove: (file: Partial<File>, user: User) => boolean;
|
|
128
135
|
export declare const canValidate: ({ status, isPrivate }: Partial<File>, { admin }: Partial<User>) => boolean;
|
|
129
136
|
export declare const isValidated: ({ validatedAt, status }: Partial<File>) => boolean;
|
|
130
137
|
export declare const canSubmit: (file: Partial<File>, user: User) => boolean;
|
|
138
|
+
export declare const canFeedback: ({ status }: File) => boolean;
|
|
131
139
|
export declare const isDraft: ({ filepath, filename }: Partial<File>) => 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.canSubmit = exports.isValidated = exports.canValidate = exports.isAuthorized = exports.isOwner = 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.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.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;
|
|
@@ -165,6 +165,11 @@ exports.isAuthorized = function (_a, user) {
|
|
|
165
165
|
var authorizedUsers = _a.authorizedUsers;
|
|
166
166
|
return (authorizedUsers || []).map(asString).includes(asString(user));
|
|
167
167
|
};
|
|
168
|
+
exports.canRemove = function (file, user) {
|
|
169
|
+
return user.admin ||
|
|
170
|
+
!exports.isValidated(file) ||
|
|
171
|
+
file.isPrivate;
|
|
172
|
+
};
|
|
168
173
|
var validateStatuses = [
|
|
169
174
|
FileStatus.validateDataDone,
|
|
170
175
|
FileStatus.indexJsonDone,
|
|
@@ -190,6 +195,14 @@ exports.canSubmit = function (file, user) {
|
|
|
190
195
|
return submitStatuses.includes(file.status) &&
|
|
191
196
|
!file.userValidatedAt && (exports.isOwner(file, user) || exports.isAuthorized(file, user));
|
|
192
197
|
};
|
|
198
|
+
var feedbackStatuses = [
|
|
199
|
+
FileStatus.validateDataDone,
|
|
200
|
+
FileError.validateDataError
|
|
201
|
+
];
|
|
202
|
+
exports.canFeedback = function (_a) {
|
|
203
|
+
var status = _a.status;
|
|
204
|
+
return feedbackStatuses.includes(status);
|
|
205
|
+
};
|
|
193
206
|
exports.isDraft = function (_a) {
|
|
194
207
|
var filepath = _a.filepath, filename = _a.filename;
|
|
195
208
|
return (filepath || filename || '').endsWith(SupportedExtensions.draft);
|
|
@@ -117,7 +117,7 @@ var includeBlankNodes = function (logs, log) {
|
|
|
117
117
|
}, logs);
|
|
118
118
|
};
|
|
119
119
|
var groupLog = function (group, _a) {
|
|
120
|
-
var logger = _a.logger, term = _a.term, model = _a.model, key = _a.key, should_run = _a.should_run, log = __rest(_a, ["logger", "term", "model", "key", "should_run"]);
|
|
120
|
+
var logger = _a.logger, term = _a.term, model = _a.model, key = _a.key, should_run = _a.should_run, run_required = _a.run_required, log = __rest(_a, ["logger", "term", "model", "key", "should_run", "run_required"]);
|
|
121
121
|
var isOrchestrator = logger.includes('orchestrator');
|
|
122
122
|
var modelKey = isOrchestrator ? model : key || model;
|
|
123
123
|
var isKey = !isOrchestrator && !!key;
|
|
@@ -128,6 +128,10 @@ var groupLog = function (group, _a) {
|
|
|
128
128
|
var shouldRun = should_run === 'True';
|
|
129
129
|
group[term][modelKey] = isOrchestrator ? __assign(__assign({}, group[term][modelKey]), { shouldRunOrchestrator: shouldRun }) : __assign(__assign(__assign({}, group[term][modelKey]), omitLogKeys(log)), { shouldRun: shouldRun });
|
|
130
130
|
}
|
|
131
|
+
else if (typeof run_required !== 'undefined') {
|
|
132
|
+
var runRequired = run_required === 'True';
|
|
133
|
+
group[term][modelKey] = __assign(__assign(__assign({}, group[term][modelKey]), (runRequired ? {} : omitLogKeys(log))), { runRequired: runRequired });
|
|
134
|
+
}
|
|
131
135
|
else if ('requirements' in log) {
|
|
132
136
|
var requirements = log.requirements, logData = __rest(log, ["requirements"]);
|
|
133
137
|
group[term][modelKey].requirements = __assign(__assign({}, (group[term][modelKey].requirements || {})), logData);
|