@hestia-earth/api 0.18.6 → 0.18.7
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.
|
@@ -131,7 +131,9 @@ export declare const filepathSearch: (...parts: string[]) => {
|
|
|
131
131
|
$in: string[];
|
|
132
132
|
};
|
|
133
133
|
};
|
|
134
|
+
export declare const fileExt: (path: string) => string;
|
|
134
135
|
export declare const fileToExt: (path: string, extension: string) => string;
|
|
136
|
+
export declare const filenameWithoutExt: (filename?: string) => string;
|
|
135
137
|
export declare const validPathChars = "A-Za-z\\d.\\-_";
|
|
136
138
|
export declare const replaceInvalidChars: (value: string) => string;
|
|
137
139
|
export declare const folderFromPath: (path: string) => string;
|
|
@@ -147,6 +149,7 @@ export declare const isOwner: (file: Partial<File>, user: User) => boolean;
|
|
|
147
149
|
export declare const isAuthorized: ({ authorizedUsers }: Partial<File>, user: User) => boolean;
|
|
148
150
|
export declare const isAssigned: ({ assignedUsers }: Partial<File>, user: User) => boolean;
|
|
149
151
|
export declare const canRemove: (file: Partial<File>, user: User) => boolean;
|
|
152
|
+
export declare const validatedStatuses: FileStatus[];
|
|
150
153
|
export declare const canValidate: ({ status, isPrivate, archived }: Partial<File>, user: Partial<User>) => boolean;
|
|
151
154
|
export declare const isValidated: ({ validatedAt, status }: Partial<File>) => boolean;
|
|
152
155
|
export declare const canSubmit: (file: Partial<File>, user: User) => 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.canEditComment = exports.isDraft = exports.canFeedback = exports.canSubmit = exports.isValidated = exports.canValidate = exports.canRemove = exports.isAssigned = 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;
|
|
23
|
+
exports.canEditComment = exports.isDraft = exports.canFeedback = exports.canSubmit = exports.isValidated = exports.canValidate = exports.validatedStatuses = exports.canRemove = exports.isAssigned = 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.filenameWithoutExt = exports.fileToExt = exports.fileExt = 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
25
|
var model_1 = require("../../users/model/model");
|
|
26
26
|
exports.mb = 1048576;
|
|
@@ -138,9 +138,15 @@ exports.filepathSearch = function () {
|
|
|
138
138
|
}
|
|
139
139
|
return fileNoExtSearch.apply(void 0, __spreadArrays(['filepath'], parts));
|
|
140
140
|
};
|
|
141
|
+
exports.fileExt = function (path) { return path.split('.').pop(); };
|
|
141
142
|
exports.fileToExt = function (path, extension) {
|
|
142
143
|
return [path.split('.')[0], extension.startsWith('.') ? extension.substring(1) : extension].join('.');
|
|
143
144
|
};
|
|
145
|
+
exports.filenameWithoutExt = function (filename) {
|
|
146
|
+
if (filename === void 0) { filename = ''; }
|
|
147
|
+
var file = exports.fileToExt(exports.filenameFromPath(filename), '');
|
|
148
|
+
return file.endsWith('.') ? file.substring(0, file.length - 1) : file;
|
|
149
|
+
};
|
|
144
150
|
exports.validPathChars = 'A-Za-z\\d.\\-_';
|
|
145
151
|
exports.replaceInvalidChars = function (value) {
|
|
146
152
|
return value
|
|
@@ -188,6 +194,10 @@ var validateStatuses = [
|
|
|
188
194
|
FileStatus.indexJsonDone,
|
|
189
195
|
FileError.indexJsonError
|
|
190
196
|
];
|
|
197
|
+
exports.validatedStatuses = [
|
|
198
|
+
FileStatus.indexJsonDone,
|
|
199
|
+
FileStatus.copyHestiaDone
|
|
200
|
+
];
|
|
191
201
|
exports.canValidate = function (_a, user) {
|
|
192
202
|
var status = _a.status, isPrivate = _a.isPrivate, archived = _a.archived;
|
|
193
203
|
return !archived && validateStatuses.includes(status) && (isPrivate || model_1.isReviewer(user));
|
|
@@ -195,10 +205,7 @@ exports.canValidate = function (_a, user) {
|
|
|
195
205
|
exports.isValidated = function (_a) {
|
|
196
206
|
var validatedAt = _a.validatedAt, status = _a.status;
|
|
197
207
|
return !!validatedAt ||
|
|
198
|
-
|
|
199
|
-
FileStatus.indexJsonDone,
|
|
200
|
-
FileStatus.copyHestiaDone
|
|
201
|
-
].includes(status);
|
|
208
|
+
exports.validatedStatuses.includes(status);
|
|
202
209
|
};
|
|
203
210
|
var submitStatuses = [
|
|
204
211
|
FileStatus.validateDataDone
|