@hestia-earth/api 0.10.1-1 → 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.
|
@@ -123,6 +123,8 @@ export declare const isGlossary: (path: string) => boolean;
|
|
|
123
123
|
export declare const aggregationFolder = "aggregation";
|
|
124
124
|
export declare const isAggregation: (path: string) => boolean;
|
|
125
125
|
export declare const isFolderUpload: (path: string) => boolean;
|
|
126
|
+
export declare const canValidate: ({ status, isPrivate }: Partial<File>, { admin }: Partial<User>) => boolean;
|
|
126
127
|
export declare const isValidated: ({ validatedAt, status }: Partial<File>) => boolean;
|
|
128
|
+
export declare const canSubmit: ({ status, userValidatedAt, isOwner, isAuthorized }: Partial<File>) => boolean;
|
|
127
129
|
export declare const isDraft: ({ filepath, filename }: Partial<File>) => boolean;
|
|
128
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.isAuthorized = 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,6 +171,13 @@ 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);
|