@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.
- package/dist/aggregations/model/model.d.ts +1 -1
- package/dist/aggregations/model/model.js +30 -39
- package/dist/analyses/model/model.js +11 -24
- package/dist/api-calls/model/model.js +6 -23
- package/dist/cycles/model/model.js +1 -1
- package/dist/db/model.base.js +5 -5
- package/dist/earth-engine/model/model.js +2 -2
- package/dist/files/model/model.d.ts +1 -1
- package/dist/files/model/model.js +133 -174
- package/dist/migrations/model/model.js +6 -24
- package/dist/nodes/model/model.js +58 -94
- package/dist/reconciliations/model/model.js +13 -24
- package/dist/reconciliations/model/validations.js +51 -77
- package/dist/settings/model/model.js +7 -24
- package/dist/users/model/model.d.ts +4 -4
- package/dist/users/model/model.js +71 -77
- package/package.json +28 -19
|
@@ -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
|
-
|
|
31
|
-
|
|
5
|
+
const model_base_1 = require("../../db/model.base");
|
|
6
|
+
const model_1 = require("../../users/model/model");
|
|
32
7
|
exports.mb = 1048576;
|
|
33
|
-
|
|
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
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
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
|
-
|
|
174
|
-
|
|
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
|
-
|
|
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
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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(
|
|
200
|
+
.replace(new RegExp(`[^${exports.validPathChars}]`, 'g'), '_')
|
|
210
201
|
.replace(new RegExp(Object.values(SupportedExtensions)
|
|
211
|
-
.map(
|
|
202
|
+
.map(v => `(\_${v})`)
|
|
212
203
|
.join('|'), 'g'), '')
|
|
213
204
|
.replace(/[\_]{2,}/g, '_'))
|
|
214
205
|
: null;
|
|
215
206
|
return newFilename
|
|
216
|
-
?
|
|
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
|
-
|
|
213
|
+
const canUseFolder = (value) => !!value && !(0, exports.isFolderUpload)(value.toLowerCase());
|
|
223
214
|
exports.canUseFolder = canUseFolder;
|
|
224
|
-
|
|
215
|
+
const canUploadFolderFile = (value) => !!value && (0, exports.isSupportedExt)(value) && (0, exports.isFolderUpload)(value);
|
|
225
216
|
exports.canUploadFolderFile = canUploadFolderFile;
|
|
226
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
223
|
+
const folderFromPath = (path) => (path?.includes('.') ? path.split('/').slice(0, -1).join('/') : path);
|
|
239
224
|
exports.folderFromPath = folderFromPath;
|
|
240
|
-
|
|
225
|
+
const rootFolderFromPath = (path) => path.split('/')[0];
|
|
241
226
|
exports.rootFolderFromPath = rootFolderFromPath;
|
|
242
|
-
|
|
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
|
-
|
|
233
|
+
const isAnalysis = (path) => (0, exports.rootFolderFromPath)(path) === exports.analysesFolder;
|
|
249
234
|
exports.isAnalysis = isAnalysis;
|
|
250
|
-
|
|
235
|
+
const isReconciliation = (path) => (0, exports.rootFolderFromPath)(path) === exports.reconciliationFolder;
|
|
251
236
|
exports.isReconciliation = isReconciliation;
|
|
252
|
-
|
|
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
|
-
|
|
239
|
+
const isGlossary = (path) => (0, exports.rootFolderFromPath)(path) === exports.glossaryFolder;
|
|
257
240
|
exports.isGlossary = isGlossary;
|
|
258
|
-
|
|
241
|
+
const isTerm = (path) => (0, exports.rootFolderFromPath)(path) === exports.termFolder;
|
|
259
242
|
exports.isTerm = isTerm;
|
|
260
243
|
exports.aggregationFolder = 'aggregation';
|
|
261
|
-
|
|
244
|
+
const isAggregation = (path) => (0, exports.rootFolderFromPath)(path) === exports.aggregationFolder;
|
|
262
245
|
exports.isAggregation = isAggregation;
|
|
263
|
-
|
|
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
|
-
|
|
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
|
-
|
|
273
|
-
|
|
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
|
-
|
|
253
|
+
const isOwner = (file, user) => asString(file?.user) === asString(user);
|
|
276
254
|
exports.isOwner = isOwner;
|
|
277
|
-
|
|
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
|
-
|
|
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
|
-
|
|
259
|
+
const canRemove = (file, user) => (0, model_1.isAdmin)(user) || !(0, exports.isValidated)(file) || file.isPrivate;
|
|
288
260
|
exports.canRemove = canRemove;
|
|
289
|
-
|
|
261
|
+
const validateStatuses = [FileStatus.validateDataDone, FileStatus.indexJsonDone, FileError.indexJsonError];
|
|
290
262
|
exports.validatedStatuses = [FileStatus.copyHestiaDone, FileStatus.processJsonDone, FileStatus.indexJsonDone];
|
|
291
|
-
|
|
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
|
-
|
|
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
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
-
|
|
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
|
-
|
|
275
|
+
const canEditComment = (comment, user) => asString(comment?.user) === asString(user);
|
|
315
276
|
exports.canEditComment = canEditComment;
|
|
316
|
-
|
|
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
|
-
|
|
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
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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;
|