@hestia-earth/api 0.25.46 → 0.25.47

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.
@@ -1,36 +1,11 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
19
- if (ar || !(i in from)) {
20
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21
- ar[i] = from[i];
22
- }
23
- }
24
- return to.concat(ar || Array.prototype.slice.call(from));
25
- };
26
- var _a;
27
2
  Object.defineProperty(exports, "__esModule", { value: true });
28
3
  exports.isAssigned = exports.isAuthorized = exports.isOwner = exports.userFolder = exports.isFolderUpload = exports.isAdminFolder = exports.isAggregation = exports.aggregationFolder = exports.isTerm = exports.isGlossary = exports.hasReconciliationAccess = exports.isReconciliation = exports.isAnalysis = exports.reconciliationFolder = exports.termFolder = exports.glossaryFolder = exports.analysesFolder = exports.filenameFromPath = exports.rootFolderFromPath = exports.folderFromPath = exports.normalizeFolder = exports.isFilepathValid = exports.isFilenameValid = exports.canUploadFolderFile = exports.canUseFolder = exports.replaceInvalidChars = exports.validPathChars = exports.filenameWithoutExt = exports.fileToExt = exports.isSupportedExt = exports.fileExt = exports.filepathSearch = exports.filenameSearch = exports.File = exports.FileValidationStatus = exports.FilePipelineError = exports.FilePipelineProgress = exports.FilePipelineStatus = exports.FileError = exports.FileStatus = exports.FileProgress = exports.FileFindFields = exports.HestiaExtensions = exports.finalFormatExtensions = exports.maxFileSizeByFile = exports.SupportedExtensions = exports.maxFileSize = exports.maxFileSizeMb = exports.sizeInMb = exports.mb = void 0;
29
4
  exports.canCommitHestiaData = exports.canEditComment = exports.isDraft = exports.canSubmit = exports.isValidated = exports.canValidate = exports.validatedStatuses = exports.canRemove = void 0;
30
- var model_base_1 = require("../../db/model.base");
31
- var model_1 = require("../../users/model/model");
5
+ const model_base_1 = require("../../db/model.base");
6
+ const model_1 = require("../../users/model/model");
32
7
  exports.mb = 1048576;
33
- var sizeInMb = function (size) { return Math.round((size / exports.mb) * 1000) / 1000; };
8
+ const sizeInMb = (size) => Math.round((size / exports.mb) * 1000) / 1000;
34
9
  exports.sizeInMb = sizeInMb;
35
10
  exports.maxFileSizeMb = 100;
36
11
  exports.maxFileSize = exports.maxFileSizeMb * exports.mb;
@@ -42,16 +17,16 @@ var SupportedExtensions;
42
17
  SupportedExtensions["json"] = "json";
43
18
  SupportedExtensions["draft"] = "txt";
44
19
  SupportedExtensions["pdf"] = "pdf";
45
- })(SupportedExtensions = exports.SupportedExtensions || (exports.SupportedExtensions = {}));
46
- var maxFileSizeExt = (_a = {},
47
- _a[SupportedExtensions.csv] = exports.maxFileSize,
48
- _a[SupportedExtensions.xlsx] = exports.maxFileSize / 2,
49
- _a[SupportedExtensions.xls] = exports.maxFileSize / 2,
50
- _a[SupportedExtensions.draft] = exports.maxFileSize,
51
- _a[SupportedExtensions.json] = exports.maxFileSize,
52
- _a[SupportedExtensions.pdf] = exports.maxFileSize / 2,
53
- _a);
54
- var maxFileSizeByFile = function (filename) { return maxFileSizeExt[(0, exports.fileExt)(filename).replace('.', '')]; };
20
+ })(SupportedExtensions || (exports.SupportedExtensions = SupportedExtensions = {}));
21
+ const maxFileSizeExt = {
22
+ [SupportedExtensions.csv]: exports.maxFileSize,
23
+ [SupportedExtensions.xlsx]: exports.maxFileSize / 2,
24
+ [SupportedExtensions.xls]: exports.maxFileSize / 2,
25
+ [SupportedExtensions.draft]: exports.maxFileSize,
26
+ [SupportedExtensions.json]: exports.maxFileSize,
27
+ [SupportedExtensions.pdf]: exports.maxFileSize / 2
28
+ };
29
+ const maxFileSizeByFile = (filename) => maxFileSizeExt[(0, exports.fileExt)(filename).replace('.', '')];
55
30
  exports.maxFileSizeByFile = maxFileSizeByFile;
56
31
  exports.finalFormatExtensions = [SupportedExtensions.json, SupportedExtensions.csv];
57
32
  var HestiaExtensions;
@@ -62,7 +37,7 @@ var HestiaExtensions;
62
37
  HestiaExtensions["error"] = "err";
63
38
  HestiaExtensions["json"] = "json";
64
39
  HestiaExtensions["jsonld"] = "jsonld";
65
- })(HestiaExtensions = exports.HestiaExtensions || (exports.HestiaExtensions = {}));
40
+ })(HestiaExtensions || (exports.HestiaExtensions = HestiaExtensions = {}));
66
41
  var FileFindFields;
67
42
  (function (FileFindFields) {
68
43
  FileFindFields["sources"] = "sources";
@@ -70,7 +45,7 @@ var FileFindFields;
70
45
  FileFindFields["impactAssessments"] = "nbImpactAssessments";
71
46
  FileFindFields["users"] = "user";
72
47
  FileFindFields["hestiaData"] = "hestiaDataPath";
73
- })(FileFindFields = exports.FileFindFields || (exports.FileFindFields = {}));
48
+ })(FileFindFields || (exports.FileFindFields = FileFindFields = {}));
74
49
  var FileProgress;
75
50
  (function (FileProgress) {
76
51
  FileProgress["convertExcel"] = "convertExcel";
@@ -84,7 +59,7 @@ var FileProgress;
84
59
  FileProgress["copyHestia"] = "copyHestia";
85
60
  FileProgress["processJson"] = "processJson";
86
61
  FileProgress["indexJson"] = "indexJson";
87
- })(FileProgress = exports.FileProgress || (exports.FileProgress = {}));
62
+ })(FileProgress || (exports.FileProgress = FileProgress = {}));
88
63
  var FileStatus;
89
64
  (function (FileStatus) {
90
65
  FileStatus["convertExcelDone"] = "convertExcelDone";
@@ -98,7 +73,7 @@ var FileStatus;
98
73
  FileStatus["copyHestiaDone"] = "copyHestiaDone";
99
74
  FileStatus["processJsonDone"] = "processJsonDone";
100
75
  FileStatus["indexJsonDone"] = "indexJsonDone";
101
- })(FileStatus = exports.FileStatus || (exports.FileStatus = {}));
76
+ })(FileStatus || (exports.FileStatus = FileStatus = {}));
102
77
  var FileError;
103
78
  (function (FileError) {
104
79
  FileError["convertExcelError"] = "convertExcelError";
@@ -112,208 +87,192 @@ var FileError;
112
87
  FileError["copyHestiaError"] = "copyHestiaError";
113
88
  FileError["processJsonError"] = "processJsonError";
114
89
  FileError["indexJsonError"] = "indexJsonError";
115
- })(FileError = exports.FileError || (exports.FileError = {}));
90
+ })(FileError || (exports.FileError = FileError = {}));
116
91
  var FilePipelineStatus;
117
92
  (function (FilePipelineStatus) {
118
93
  FilePipelineStatus["indexEngineDone"] = "indexEngineDone";
119
94
  FilePipelineStatus["calculationEngineDone"] = "calculationEngineDone";
120
- })(FilePipelineStatus = exports.FilePipelineStatus || (exports.FilePipelineStatus = {}));
95
+ })(FilePipelineStatus || (exports.FilePipelineStatus = FilePipelineStatus = {}));
121
96
  var FilePipelineProgress;
122
97
  (function (FilePipelineProgress) {
123
98
  FilePipelineProgress["indexEngine"] = "indexEngine";
124
99
  FilePipelineProgress["calculationEngine"] = "calculationEngine";
125
- })(FilePipelineProgress = exports.FilePipelineProgress || (exports.FilePipelineProgress = {}));
100
+ })(FilePipelineProgress || (exports.FilePipelineProgress = FilePipelineProgress = {}));
126
101
  var FilePipelineError;
127
102
  (function (FilePipelineError) {
128
103
  FilePipelineError["indexEngineError"] = "indexEngineError";
129
104
  FilePipelineError["calculationEngineError"] = "calculationEngineError";
130
- })(FilePipelineError = exports.FilePipelineError || (exports.FilePipelineError = {}));
105
+ })(FilePipelineError || (exports.FilePipelineError = FilePipelineError = {}));
131
106
  var FileValidationStatus;
132
107
  (function (FileValidationStatus) {
133
108
  FileValidationStatus["success"] = "success";
134
109
  FileValidationStatus["error"] = "error";
135
- })(FileValidationStatus = exports.FileValidationStatus || (exports.FileValidationStatus = {}));
136
- var File = (function (_super) {
137
- __extends(File, _super);
138
- function File() {
139
- return _super !== null && _super.apply(this, arguments) || this;
140
- }
141
- return File;
142
- }(model_base_1.BaseModel));
110
+ })(FileValidationStatus || (exports.FileValidationStatus = FileValidationStatus = {}));
111
+ class File extends model_base_1.BaseModel {
112
+ filename;
113
+ filepath;
114
+ folder;
115
+ user;
116
+ assignedUsers;
117
+ authorizedUsers;
118
+ contentType;
119
+ archived;
120
+ status;
121
+ pipelineStatus;
122
+ validationStatus;
123
+ userValidatedAt;
124
+ validatedUser;
125
+ validatedAt;
126
+ schemaVersion;
127
+ schemaOutdated;
128
+ glossaryOutdated;
129
+ comments;
130
+ todos;
131
+ metadata;
132
+ isPrivate;
133
+ skipValidation;
134
+ study;
135
+ fromDraft;
136
+ deleted;
137
+ isOwner;
138
+ isAuthorized;
139
+ isAssignedToMe;
140
+ isValidated;
141
+ isDraft;
142
+ originalPath;
143
+ hestiaPath;
144
+ progressPath;
145
+ studyPath;
146
+ dataPath;
147
+ dataProgressPath;
148
+ dataCsvPath;
149
+ dataRecalculatedCsvPath;
150
+ dataRecalculatedStatusPath;
151
+ logPath;
152
+ errorPath;
153
+ sources;
154
+ nbCycles;
155
+ nbImpactAssessments;
156
+ hestiaDataPath;
157
+ }
143
158
  exports.File = File;
144
- var fileNoExtSearch = function (key) {
145
- var _a;
146
- var parts = [];
147
- for (var _i = 1; _i < arguments.length; _i++) {
148
- parts[_i - 1] = arguments[_i];
149
- }
150
- var filepathNoExt = parts.filter(Boolean).join('/').split('.')[0];
151
- return _a = {},
152
- _a[key] = {
153
- $in: Object.values(SupportedExtensions).map(function (ext) { return "".concat(filepathNoExt, ".").concat(ext); })
154
- },
155
- _a;
156
- };
157
- var filenameSearch = function () {
158
- var parts = [];
159
- for (var _i = 0; _i < arguments.length; _i++) {
160
- parts[_i] = arguments[_i];
161
- }
162
- return ((parts === null || parts === void 0 ? void 0 : parts.length) ? fileNoExtSearch.apply(void 0, __spreadArray(['filename'], parts, false)) : {});
159
+ const fileNoExtSearch = (key, ...parts) => {
160
+ const [filepathNoExt] = parts.filter(Boolean).join('/').split('.');
161
+ return {
162
+ [key]: {
163
+ $in: Object.values(SupportedExtensions).map(ext => `${filepathNoExt}.${ext}`)
164
+ }
165
+ };
163
166
  };
167
+ const filenameSearch = (...parts) => (parts?.length ? fileNoExtSearch('filename', ...parts) : {});
164
168
  exports.filenameSearch = filenameSearch;
165
- var filepathSearch = function () {
166
- var parts = [];
167
- for (var _i = 0; _i < arguments.length; _i++) {
168
- parts[_i] = arguments[_i];
169
- }
170
- return ((parts === null || parts === void 0 ? void 0 : parts.length) ? fileNoExtSearch.apply(void 0, __spreadArray(['filepath'], parts, false)) : {});
171
- };
169
+ const filepathSearch = (...parts) => (parts?.length ? fileNoExtSearch('filepath', ...parts) : {});
172
170
  exports.filepathSearch = filepathSearch;
173
- var fileExt = function (path) {
174
- var _a, _b;
175
- var paths = (_b = (_a = path === null || path === void 0 ? void 0 : path.split('/')) === null || _a === void 0 ? void 0 : _a.pop()) === null || _b === void 0 ? void 0 : _b.split('.');
171
+ const fileExt = (path) => {
172
+ const paths = path?.split('/')?.pop()?.split('.');
176
173
  return paths.length > 1 ? paths.pop() : null;
177
174
  };
178
175
  exports.fileExt = fileExt;
179
- var isSupportedExt = function (path) {
180
- return Object.values(SupportedExtensions).includes((0, exports.fileExt)(path));
181
- };
176
+ const isSupportedExt = (path) => Object.values(SupportedExtensions).includes((0, exports.fileExt)(path));
182
177
  exports.isSupportedExt = isSupportedExt;
183
- var fileToExt = function (path, extension) {
184
- if (extension === void 0) { extension = ''; }
185
- return [
186
- path
187
- .replace(".".concat((0, exports.fileExt)(path)), '')
188
- .replace(/^\./g, '')
189
- .replace(/\.$/g, ''),
190
- (extension || '').replace(/[.]/g, '')
191
- ]
192
- .filter(Boolean)
193
- .join('.');
194
- };
178
+ const fileToExt = (path, extension = '') => [
179
+ path
180
+ .replace(`.${(0, exports.fileExt)(path)}`, '')
181
+ .replace(/^\./g, '')
182
+ .replace(/\.$/g, ''),
183
+ (extension || '').replace(/[.]/g, '')
184
+ ]
185
+ .filter(Boolean)
186
+ .join('.');
195
187
  exports.fileToExt = fileToExt;
196
- var filenameWithoutExt = function (filepath) {
197
- if (filepath === void 0) { filepath = ''; }
198
- var filename = (0, exports.filenameFromPath)(filepath);
199
- var file = (0, exports.fileToExt)(filename, '');
188
+ const filenameWithoutExt = (filepath = '') => {
189
+ const filename = (0, exports.filenameFromPath)(filepath);
190
+ const file = (0, exports.fileToExt)(filename, '');
200
191
  return file.endsWith('.') ? file.substring(0, file.length - 1) : file;
201
192
  };
202
193
  exports.filenameWithoutExt = filenameWithoutExt;
203
194
  exports.validPathChars = 'A-Za-z\\d\\-_';
204
- var rstripChar = function (value) { return (value.length > 1 ? value.replace(/(\.|\_)$/g, '') : value); };
205
- var replaceInvalidChars = function (value) {
206
- var folder = (0, exports.folderFromPath)(value);
207
- var newFilename = value
195
+ const rstripChar = (value) => (value.length > 1 ? value.replace(/(\.|\_)$/g, '') : value);
196
+ const replaceInvalidChars = (value) => {
197
+ const folder = (0, exports.folderFromPath)(value);
198
+ const newFilename = value
208
199
  ? rstripChar(rstripChar((0, exports.filenameWithoutExt)(value))
209
- .replace(new RegExp("[^".concat(exports.validPathChars, "]"), 'g'), '_')
200
+ .replace(new RegExp(`[^${exports.validPathChars}]`, 'g'), '_')
210
201
  .replace(new RegExp(Object.values(SupportedExtensions)
211
- .map(function (v) { return "(_".concat(v, ")"); })
202
+ .map(v => `(\_${v})`)
212
203
  .join('|'), 'g'), '')
213
204
  .replace(/[\_]{2,}/g, '_'))
214
205
  : null;
215
206
  return newFilename
216
- ? (value === null || value === void 0 ? void 0 : value.includes('.'))
207
+ ? value?.includes('.')
217
208
  ? [(0, exports.normalizeFolder)(folder), (0, exports.fileToExt)(newFilename, (0, exports.fileExt)(value))].filter(Boolean).join('/')
218
209
  : newFilename
219
210
  : value;
220
211
  };
221
212
  exports.replaceInvalidChars = replaceInvalidChars;
222
- var canUseFolder = function (value) { return !!value && !(0, exports.isFolderUpload)(value.toLowerCase()); };
213
+ const canUseFolder = (value) => !!value && !(0, exports.isFolderUpload)(value.toLowerCase());
223
214
  exports.canUseFolder = canUseFolder;
224
- var canUploadFolderFile = function (value) { return !!value && (0, exports.isSupportedExt)(value) && (0, exports.isFolderUpload)(value); };
215
+ const canUploadFolderFile = (value) => !!value && (0, exports.isSupportedExt)(value) && (0, exports.isFolderUpload)(value);
225
216
  exports.canUploadFolderFile = canUploadFolderFile;
226
- var isFilenameValid = function (filename) {
227
- return !!filename && filename.split('.').filter(Boolean).length > 1 && (0, exports.isSupportedExt)(filename);
228
- };
217
+ const isFilenameValid = (filename) => !!filename && filename.split('.').filter(Boolean).length > 1 && (0, exports.isSupportedExt)(filename);
229
218
  exports.isFilenameValid = isFilenameValid;
230
- var isFilepathValid = function (filepath) {
231
- return !!filepath && [(0, exports.isSupportedExt)(filepath), (0, exports.canUseFolder)(filepath)].every(Boolean);
232
- };
219
+ const isFilepathValid = (filepath) => !!filepath && [(0, exports.isSupportedExt)(filepath), (0, exports.canUseFolder)(filepath)].every(Boolean);
233
220
  exports.isFilepathValid = isFilepathValid;
234
- var normalizeFolder = function (folder) {
235
- return folder.replace(new RegExp("[^".concat(exports.validPathChars, "]"), 'g'), '_').replace(/[\_]{2,}/g, '_');
236
- };
221
+ const normalizeFolder = (folder) => folder.replace(new RegExp(`[^${exports.validPathChars}]`, 'g'), '_').replace(/[\_]{2,}/g, '_');
237
222
  exports.normalizeFolder = normalizeFolder;
238
- var folderFromPath = function (path) { return ((path === null || path === void 0 ? void 0 : path.includes('.')) ? path.split('/').slice(0, -1).join('/') : path); };
223
+ const folderFromPath = (path) => (path?.includes('.') ? path.split('/').slice(0, -1).join('/') : path);
239
224
  exports.folderFromPath = folderFromPath;
240
- var rootFolderFromPath = function (path) { return path.split('/')[0]; };
225
+ const rootFolderFromPath = (path) => path.split('/')[0];
241
226
  exports.rootFolderFromPath = rootFolderFromPath;
242
- var filenameFromPath = function (path) { return path.split('/').pop(); };
227
+ const filenameFromPath = (path) => path.split('/').pop();
243
228
  exports.filenameFromPath = filenameFromPath;
244
229
  exports.analysesFolder = 'analyses';
245
230
  exports.glossaryFolder = 'glossary';
246
231
  exports.termFolder = 'term';
247
232
  exports.reconciliationFolder = 'reconciliation';
248
- var isAnalysis = function (path) { return (0, exports.rootFolderFromPath)(path) === exports.analysesFolder; };
233
+ const isAnalysis = (path) => (0, exports.rootFolderFromPath)(path) === exports.analysesFolder;
249
234
  exports.isAnalysis = isAnalysis;
250
- var isReconciliation = function (path) { return (0, exports.rootFolderFromPath)(path) === exports.reconciliationFolder; };
235
+ const isReconciliation = (path) => (0, exports.rootFolderFromPath)(path) === exports.reconciliationFolder;
251
236
  exports.isReconciliation = isReconciliation;
252
- var hasReconciliationAccess = function (file, user) {
253
- return 'idRecalculated' in file && (0, model_1.hasPermission)(model_1.UserPermission.reconciliationsRead, user);
254
- };
237
+ const hasReconciliationAccess = (file, user) => 'idRecalculated' in file && (0, model_1.hasPermission)(model_1.UserPermission.reconciliationsRead, user);
255
238
  exports.hasReconciliationAccess = hasReconciliationAccess;
256
- var isGlossary = function (path) { return (0, exports.rootFolderFromPath)(path) === exports.glossaryFolder; };
239
+ const isGlossary = (path) => (0, exports.rootFolderFromPath)(path) === exports.glossaryFolder;
257
240
  exports.isGlossary = isGlossary;
258
- var isTerm = function (path) { return (0, exports.rootFolderFromPath)(path) === exports.termFolder; };
241
+ const isTerm = (path) => (0, exports.rootFolderFromPath)(path) === exports.termFolder;
259
242
  exports.isTerm = isTerm;
260
243
  exports.aggregationFolder = 'aggregation';
261
- var isAggregation = function (path) { return (0, exports.rootFolderFromPath)(path) === exports.aggregationFolder; };
244
+ const isAggregation = (path) => (0, exports.rootFolderFromPath)(path) === exports.aggregationFolder;
262
245
  exports.isAggregation = isAggregation;
263
- var isAdminFolder = function (path) {
264
- return !!path && [exports.isTerm, exports.isAnalysis, exports.isAggregation, exports.isReconciliation].some(function (f) { return f(path); });
265
- };
246
+ const isAdminFolder = (path) => !!path && [exports.isTerm, exports.isAnalysis, exports.isAggregation, exports.isReconciliation].some(f => f(path));
266
247
  exports.isAdminFolder = isAdminFolder;
267
- var isFolderUpload = function (path, termsOnly) {
268
- if (termsOnly === void 0) { termsOnly = false; }
269
- return __spreadArray([exports.isGlossary, exports.isTerm], (termsOnly ? [] : [exports.isAggregation, exports.isReconciliation]), true).some(function (f) { return f(path); });
270
- };
248
+ const isFolderUpload = (path, termsOnly = false) => [exports.isGlossary, exports.isTerm, ...(termsOnly ? [] : [exports.isAggregation, exports.isReconciliation])].some(f => f(path));
271
249
  exports.isFolderUpload = isFolderUpload;
272
- var asString = function (v) { var _a, _b; return (typeof v === 'object' ? ((_a = v === null || v === void 0 ? void 0 : v._id) === null || _a === void 0 ? void 0 : _a.toString()) || ((_b = v === null || v === void 0 ? void 0 : v.id) === null || _b === void 0 ? void 0 : _b.toString()) : v === null || v === void 0 ? void 0 : v.toString()); };
273
- var userFolder = function (user) { return asString(user); };
250
+ const asString = (v) => (typeof v === 'object' ? v?._id?.toString() || v?.id?.toString() : v?.toString());
251
+ const userFolder = (user) => asString(user);
274
252
  exports.userFolder = userFolder;
275
- var isOwner = function (file, user) { return asString(file === null || file === void 0 ? void 0 : file.user) === asString(user); };
253
+ const isOwner = (file, user) => asString(file?.user) === asString(user);
276
254
  exports.isOwner = isOwner;
277
- var isAuthorized = function (_a, user) {
278
- var authorizedUsers = _a.authorizedUsers;
279
- return (authorizedUsers || []).map(asString).includes(asString(user));
280
- };
255
+ const isAuthorized = ({ authorizedUsers }, user) => (authorizedUsers || []).map(asString).includes(asString(user));
281
256
  exports.isAuthorized = isAuthorized;
282
- var isAssigned = function (_a, user) {
283
- var assignedUsers = _a.assignedUsers;
284
- return (assignedUsers || []).map(asString).includes(asString(user));
285
- };
257
+ const isAssigned = ({ assignedUsers }, user) => (assignedUsers || []).map(asString).includes(asString(user));
286
258
  exports.isAssigned = isAssigned;
287
- var canRemove = function (file, user) { return (0, model_1.isAdmin)(user) || !(0, exports.isValidated)(file) || file.isPrivate; };
259
+ const canRemove = (file, user) => (0, model_1.isAdmin)(user) || !(0, exports.isValidated)(file) || file.isPrivate;
288
260
  exports.canRemove = canRemove;
289
- var validateStatuses = [FileStatus.validateDataDone, FileStatus.indexJsonDone, FileError.indexJsonError];
261
+ const validateStatuses = [FileStatus.validateDataDone, FileStatus.indexJsonDone, FileError.indexJsonError];
290
262
  exports.validatedStatuses = [FileStatus.copyHestiaDone, FileStatus.processJsonDone, FileStatus.indexJsonDone];
291
- var canValidate = function (_a, user) {
292
- var status = _a.status, isPrivate = _a.isPrivate, archived = _a.archived;
293
- return !archived && validateStatuses.includes(status) && (isPrivate || (0, model_1.isReviewer)(user));
294
- };
263
+ const canValidate = ({ status, isPrivate, archived }, user) => !archived && validateStatuses.includes(status) && (isPrivate || (0, model_1.isReviewer)(user));
295
264
  exports.canValidate = canValidate;
296
- var isValidated = function (_a) {
297
- var validatedAt = _a.validatedAt, status = _a.status;
298
- return !!validatedAt || exports.validatedStatuses.includes(status);
299
- };
265
+ const isValidated = ({ validatedAt, status }) => !!validatedAt || exports.validatedStatuses.includes(status);
300
266
  exports.isValidated = isValidated;
301
- var submitStatuses = [FileStatus.validateDataDone];
302
- var canSubmit = function (file, user) {
303
- return !file.archived &&
304
- submitStatuses.includes(file.status) &&
305
- !file.userValidatedAt &&
306
- ((0, exports.isOwner)(file, user) || (0, exports.isAuthorized)(file, user));
307
- };
267
+ const submitStatuses = [FileStatus.validateDataDone];
268
+ const canSubmit = (file, user) => !file.archived &&
269
+ submitStatuses.includes(file.status) &&
270
+ !file.userValidatedAt &&
271
+ ((0, exports.isOwner)(file, user) || (0, exports.isAuthorized)(file, user));
308
272
  exports.canSubmit = canSubmit;
309
- var isDraft = function (_a) {
310
- var filepath = _a.filepath, filename = _a.filename;
311
- return (filepath || filename || '').endsWith(SupportedExtensions.draft);
312
- };
273
+ const isDraft = ({ filepath, filename }) => (filepath || filename || '').endsWith(SupportedExtensions.draft);
313
274
  exports.isDraft = isDraft;
314
- var canEditComment = function (comment, user) { return asString(comment === null || comment === void 0 ? void 0 : comment.user) === asString(user); };
275
+ const canEditComment = (comment, user) => asString(comment?.user) === asString(user);
315
276
  exports.canEditComment = canEditComment;
316
- var canCommitHestiaData = function (file, user) {
317
- return !file.archived && (0, exports.isValidated)(file) && ((0, model_1.isReviewer)(user) || (user === null || user === void 0 ? void 0 : user.canCommitHestiaData));
318
- };
277
+ const canCommitHestiaData = (file, user) => !file.archived && (0, exports.isValidated)(file) && ((0, model_1.isReviewer)(user) || user?.canCommitHestiaData);
319
278
  exports.canCommitHestiaData = canCommitHestiaData;
@@ -1,32 +1,14 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.Migration = exports.MigrationType = void 0;
19
- var model_base_1 = require("../../db/model.base");
4
+ const model_base_1 = require("../../db/model.base");
20
5
  var MigrationType;
21
6
  (function (MigrationType) {
22
7
  MigrationType["glossary"] = "glossary";
23
8
  MigrationType["schema"] = "schema";
24
- })(MigrationType = exports.MigrationType || (exports.MigrationType = {}));
25
- var Migration = (function (_super) {
26
- __extends(Migration, _super);
27
- function Migration() {
28
- return _super !== null && _super.apply(this, arguments) || this;
29
- }
30
- return Migration;
31
- }(model_base_1.BaseModel));
9
+ })(MigrationType || (exports.MigrationType = MigrationType = {}));
10
+ class Migration extends model_base_1.BaseModel {
11
+ filenames;
12
+ type;
13
+ }
32
14
  exports.Migration = Migration;