@hestia-earth/api 0.18.9 → 0.18.11

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.
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
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");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
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");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPrimaryProduct = void 0;
4
- exports.getPrimaryProduct = function (products) { return (products || []).find(function (product) { return product.primary === true; }); };
4
+ var getPrimaryProduct = function (products) { return (products || []).find(function (product) { return product.primary === true; }); };
5
+ exports.getPrimaryProduct = getPrimaryProduct;
@@ -32,4 +32,4 @@ export interface IEarthEngineParamsGadm extends IEarthEngineParams {
32
32
  gadm_id?: string;
33
33
  max_area?: number;
34
34
  }
35
- export declare type earthEngineParams = IEarthEngineParamsBoundary | IEarthEngineParamsCoordinates | IEarthEngineParamsGadm;
35
+ export type earthEngineParams = IEarthEngineParamsBoundary | IEarthEngineParamsCoordinates | IEarthEngineParamsGadm;
@@ -57,7 +57,7 @@ export declare enum FileError {
57
57
  copyHestiaError = "copyHestiaError",
58
58
  indexJsonError = "indexJsonError"
59
59
  }
60
- export declare type status = FileStatus | FileProgress | FileError;
60
+ export type status = FileStatus | FileProgress | FileError;
61
61
  export declare enum FilePipelineStatus {
62
62
  indexEngineDone = "indexEngineDone",
63
63
  calculationEngineDone = "calculationEngineDone"
@@ -70,7 +70,7 @@ export declare enum FilePipelineError {
70
70
  indexEngineError = "indexEngineError",
71
71
  calculationEngineError = "calculationEngineError"
72
72
  }
73
- export declare type pipelineStatus = FilePipelineStatus | FilePipelineProgress | FilePipelineError;
73
+ export type pipelineStatus = FilePipelineStatus | FilePipelineProgress | FilePipelineError;
74
74
  export interface IFileComment {
75
75
  content: string;
76
76
  date: Date;
@@ -3,21 +3,25 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
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");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
15
  };
14
16
  })();
15
- var __spreadArrays = (this && this.__spreadArrays) || function () {
16
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
17
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
18
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
19
- r[k] = a[j];
20
- return r;
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));
21
25
  };
22
26
  Object.defineProperty(exports, "__esModule", { value: true });
23
27
  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;
@@ -26,7 +30,8 @@ var model_1 = require("../../users/model/model");
26
30
  exports.mb = 1048576;
27
31
  exports.MAX_SIZE = 2;
28
32
  exports.MAX_SIZE_MB = 2 * exports.mb;
29
- exports.sizeInMb = function (size) { return Math.round((size / exports.mb) * 1000) / 1000; };
33
+ var sizeInMb = function (size) { return Math.round((size / exports.mb) * 1000) / 1000; };
34
+ exports.sizeInMb = sizeInMb;
30
35
  var SupportedExtensions;
31
36
  (function (SupportedExtensions) {
32
37
  SupportedExtensions["xlsx"] = "xlsx";
@@ -120,75 +125,91 @@ var fileNoExtSearch = function (key) {
120
125
  var filepathNoExt = parts.filter(Boolean).join('/').split('.')[0];
121
126
  return _a = {},
122
127
  _a[key] = {
123
- $in: Object.values(SupportedExtensions).map(function (ext) { return filepathNoExt + "." + ext; })
128
+ $in: Object.values(SupportedExtensions).map(function (ext) { return "".concat(filepathNoExt, ".").concat(ext); })
124
129
  },
125
130
  _a;
126
131
  };
127
- exports.filenameSearch = function () {
132
+ var filenameSearch = function () {
128
133
  var parts = [];
129
134
  for (var _i = 0; _i < arguments.length; _i++) {
130
135
  parts[_i] = arguments[_i];
131
136
  }
132
- return fileNoExtSearch.apply(void 0, __spreadArrays(['filename'], parts));
137
+ return fileNoExtSearch.apply(void 0, __spreadArray(['filename'], parts, false));
133
138
  };
134
- exports.filepathSearch = function () {
139
+ exports.filenameSearch = filenameSearch;
140
+ var filepathSearch = function () {
135
141
  var parts = [];
136
142
  for (var _i = 0; _i < arguments.length; _i++) {
137
143
  parts[_i] = arguments[_i];
138
144
  }
139
- return fileNoExtSearch.apply(void 0, __spreadArrays(['filepath'], parts));
145
+ return fileNoExtSearch.apply(void 0, __spreadArray(['filepath'], parts, false));
140
146
  };
141
- exports.fileExt = function (path) { return path.split('.').pop(); };
142
- exports.fileToExt = function (path, extension) {
147
+ exports.filepathSearch = filepathSearch;
148
+ var fileExt = function (path) { return path.split('.').pop(); };
149
+ exports.fileExt = fileExt;
150
+ var fileToExt = function (path, extension) {
143
151
  return [path.split('.')[0], extension.startsWith('.') ? extension.substring(1) : extension].join('.');
144
152
  };
145
- exports.filenameWithoutExt = function (filename) {
153
+ exports.fileToExt = fileToExt;
154
+ var filenameWithoutExt = function (filename) {
146
155
  if (filename === void 0) { filename = ''; }
147
- var file = exports.fileToExt(exports.filenameFromPath(filename), '');
156
+ var file = (0, exports.fileToExt)((0, exports.filenameFromPath)(filename), '');
148
157
  return file.endsWith('.') ? file.substring(0, file.length - 1) : file;
149
158
  };
159
+ exports.filenameWithoutExt = filenameWithoutExt;
150
160
  exports.validPathChars = 'A-Za-z\\d.\\-_';
151
- exports.replaceInvalidChars = function (value) {
161
+ var replaceInvalidChars = function (value) {
152
162
  return value
153
163
  ? value
154
164
  .replace(/\s/g, '_')
155
165
  .replace(/\.$/g, '')
156
- .replace(new RegExp("[^" + exports.validPathChars + "]", 'g'), '')
157
- .replace(new RegExp("(\\.)[^(" + Object.values(SupportedExtensions).map(function (v) { return "." + v; }).join('|') + ")]", 'g'), function (v) { return v.replace('.', '_'); })
166
+ .replace(new RegExp("[^".concat(exports.validPathChars, "]"), 'g'), '')
167
+ .replace(new RegExp("(\\.)[^(".concat(Object.values(SupportedExtensions).map(function (v) { return ".".concat(v); }).join('|'), ")]"), 'g'), function (v) { return v.replace('.', '_'); })
158
168
  .replace(/\^/g, '')
159
169
  : null;
160
170
  };
161
- exports.folderFromPath = function (path) {
171
+ exports.replaceInvalidChars = replaceInvalidChars;
172
+ var folderFromPath = function (path) {
162
173
  var folders = path.split('/');
163
174
  folders.pop();
164
175
  return folders.join('/');
165
176
  };
166
- exports.rootFolderFromPath = function (path) { return path.split('/')[0]; };
167
- exports.filenameFromPath = function (path) { return path.split('/').pop(); };
177
+ exports.folderFromPath = folderFromPath;
178
+ var rootFolderFromPath = function (path) { return path.split('/')[0]; };
179
+ exports.rootFolderFromPath = rootFolderFromPath;
180
+ var filenameFromPath = function (path) { return path.split('/').pop(); };
181
+ exports.filenameFromPath = filenameFromPath;
168
182
  exports.analysesFolder = 'analyses';
169
183
  exports.glossaryFolder = 'glossary';
170
- exports.isGlossary = function (path) { return exports.rootFolderFromPath(path) === exports.glossaryFolder; };
184
+ var isGlossary = function (path) { return (0, exports.rootFolderFromPath)(path) === exports.glossaryFolder; };
185
+ exports.isGlossary = isGlossary;
171
186
  exports.aggregationFolder = 'aggregation';
172
- exports.isAggregation = function (path) { return exports.rootFolderFromPath(path) === exports.aggregationFolder; };
173
- exports.isFolderUpload = function (path) { return [
187
+ var isAggregation = function (path) { return (0, exports.rootFolderFromPath)(path) === exports.aggregationFolder; };
188
+ exports.isAggregation = isAggregation;
189
+ var isFolderUpload = function (path) { return [
174
190
  exports.isAggregation,
175
191
  exports.isGlossary
176
192
  ].some(function (f) { return f(path); }); };
193
+ exports.isFolderUpload = isFolderUpload;
177
194
  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(); };
178
- exports.isOwner = function (file, user) { return asString(file === null || file === void 0 ? void 0 : file.user) === asString(user); };
179
- exports.isAuthorized = function (_a, user) {
195
+ var isOwner = function (file, user) { return asString(file === null || file === void 0 ? void 0 : file.user) === asString(user); };
196
+ exports.isOwner = isOwner;
197
+ var isAuthorized = function (_a, user) {
180
198
  var authorizedUsers = _a.authorizedUsers;
181
199
  return (authorizedUsers || []).map(asString).includes(asString(user));
182
200
  };
183
- exports.isAssigned = function (_a, user) {
201
+ exports.isAuthorized = isAuthorized;
202
+ var isAssigned = function (_a, user) {
184
203
  var assignedUsers = _a.assignedUsers;
185
204
  return (assignedUsers || []).map(asString).includes(asString(user));
186
205
  };
187
- exports.canRemove = function (file, user) {
188
- return model_1.isAdmin(user) ||
189
- !exports.isValidated(file) ||
206
+ exports.isAssigned = isAssigned;
207
+ var canRemove = function (file, user) {
208
+ return (0, model_1.isAdmin)(user) ||
209
+ !(0, exports.isValidated)(file) ||
190
210
  file.isPrivate;
191
211
  };
212
+ exports.canRemove = canRemove;
192
213
  var validateStatuses = [
193
214
  FileStatus.validateDataDone,
194
215
  FileStatus.indexJsonDone,
@@ -198,23 +219,26 @@ exports.validatedStatuses = [
198
219
  FileStatus.indexJsonDone,
199
220
  FileStatus.copyHestiaDone
200
221
  ];
201
- exports.canValidate = function (_a, user) {
222
+ var canValidate = function (_a, user) {
202
223
  var status = _a.status, isPrivate = _a.isPrivate, archived = _a.archived;
203
- return !archived && validateStatuses.includes(status) && (isPrivate || model_1.isReviewer(user));
224
+ return !archived && validateStatuses.includes(status) && (isPrivate || (0, model_1.isReviewer)(user));
204
225
  };
205
- exports.isValidated = function (_a) {
226
+ exports.canValidate = canValidate;
227
+ var isValidated = function (_a) {
206
228
  var validatedAt = _a.validatedAt, status = _a.status;
207
229
  return !!validatedAt ||
208
230
  exports.validatedStatuses.includes(status);
209
231
  };
232
+ exports.isValidated = isValidated;
210
233
  var submitStatuses = [
211
234
  FileStatus.validateDataDone
212
235
  ];
213
- exports.canSubmit = function (file, user) {
236
+ var canSubmit = function (file, user) {
214
237
  return !file.archived &&
215
238
  submitStatuses.includes(file.status) &&
216
- !file.userValidatedAt && (exports.isOwner(file, user) || exports.isAuthorized(file, user));
239
+ !file.userValidatedAt && ((0, exports.isOwner)(file, user) || (0, exports.isAuthorized)(file, user));
217
240
  };
241
+ exports.canSubmit = canSubmit;
218
242
  var feedbackStatuses = [
219
243
  FileStatus.checkExistingDone,
220
244
  FileStatus.extendBibliographyDone,
@@ -227,12 +251,15 @@ var feedbackStatuses = [
227
251
  FileError.validateHestiaError,
228
252
  FileError.validateDataError
229
253
  ];
230
- exports.canFeedback = function (_a) {
254
+ var canFeedback = function (_a) {
231
255
  var status = _a.status;
232
256
  return feedbackStatuses.includes(status);
233
257
  };
234
- exports.isDraft = function (_a) {
258
+ exports.canFeedback = canFeedback;
259
+ var isDraft = function (_a) {
235
260
  var filepath = _a.filepath, filename = _a.filename;
236
261
  return (filepath || filename || '').endsWith(SupportedExtensions.draft);
237
262
  };
238
- exports.canEditComment = function (comment, user) { return asString(comment === null || comment === void 0 ? void 0 : comment.user) === asString(user); };
263
+ exports.isDraft = isDraft;
264
+ var canEditComment = function (comment, user) { return asString(comment === null || comment === void 0 ? void 0 : comment.user) === asString(user); };
265
+ exports.canEditComment = canEditComment;
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
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");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
package/dist/models.js CHANGED
@@ -1,13 +1,17 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
8
12
  }));
9
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
13
17
  __exportStar(require("./api-calls/model/model"), exports);
@@ -27,7 +27,7 @@ exports.formatForUpload = exports.parseLogMissingLookups = exports.paramToNodeTy
27
27
  var schema_1 = require("@hestia-earth/schema");
28
28
  var utils_1 = require("@hestia-earth/utils");
29
29
  var model_1 = require("../../files/model/model");
30
- exports.blankNodeTypes = Object.values(schema_1.SchemaType).filter(function (t) { return !schema_1.isTypeNode(t); });
30
+ exports.blankNodeTypes = Object.values(schema_1.SchemaType).filter(function (t) { return !(0, schema_1.isTypeNode)(t); });
31
31
  var DataState;
32
32
  (function (DataState) {
33
33
  DataState["original"] = "original";
@@ -43,20 +43,24 @@ exports.dataStatesTypeMapping = (_a = {},
43
43
  ],
44
44
  _a[DataState.aggregated] = [],
45
45
  _a);
46
- exports.allowedDataStates = function (type) {
46
+ var allowedDataStates = function (type) {
47
47
  return Object.values(DataState).filter(function (dataState) { return exports.dataStatesTypeMapping[dataState].includes(type); });
48
48
  };
49
- exports.pathWithState = function (type, id, dataState, strictDataState) {
49
+ exports.allowedDataStates = allowedDataStates;
50
+ var pathWithState = function (type, id, dataState, strictDataState) {
50
51
  if (dataState === void 0) { dataState = DataState.original; }
51
52
  if (strictDataState === void 0) { strictDataState = false; }
52
53
  var state = exports.dataStatesTypeMapping[dataState].includes(type) ? dataState : null;
53
54
  return (state !== null || !strictDataState) ? [
54
55
  state === DataState.original ? null : state,
55
- schema_1.jsonldPath(type, id)
56
+ (0, schema_1.jsonldPath)(type, id)
56
57
  ].filter(Boolean).join('/') : null;
57
58
  };
58
- exports.nodeTypeToParam = function (type) { return (type || '').toLowerCase() + "s"; };
59
- exports.paramToNodeType = function (type) { return Object.values(schema_1.NodeType).find(function (v) { return exports.nodeTypeToParam(v) === type; }); };
59
+ exports.pathWithState = pathWithState;
60
+ var nodeTypeToParam = function (type) { return "".concat((type || '').toLowerCase(), "s"); };
61
+ exports.nodeTypeToParam = nodeTypeToParam;
62
+ var paramToNodeType = function (type) { return Object.values(schema_1.NodeType).find(function (v) { return (0, exports.nodeTypeToParam)(v) === type; }); };
63
+ exports.paramToNodeType = paramToNodeType;
60
64
  var csvValue = function (value) { return (value || '').replace('[', '').replace(']', ''); };
61
65
  var parseMessage = function (message) {
62
66
  try {
@@ -76,7 +80,7 @@ var termTypes = Object.values(schema_1.TermTermType);
76
80
  var parseFilename = function (filepath) {
77
81
  var filename = filepath.split('.')[0];
78
82
  var ext = termTypes.includes(filename) ? model_1.SupportedExtensions.xlsx : model_1.SupportedExtensions.csv;
79
- return model_1.fileToExt(filename, ext);
83
+ return (0, model_1.fileToExt)(filename, ext);
80
84
  };
81
85
  var missingLookupPrefix = 'Missing lookup';
82
86
  var parseLookup = function (_a) {
@@ -86,32 +90,34 @@ var parseLookup = function (_a) {
86
90
  column: column
87
91
  });
88
92
  };
89
- exports.parseLogMissingLookups = function (data) {
93
+ var parseLogMissingLookups = function (data) {
90
94
  var lines = data.split('\n').filter(function (log) { return log.includes(missingLookupPrefix); });
91
95
  var messages = lines.map(parseMessage).filter(function (v) { return Object.keys(v).length > 1; });
92
- return utils_1.unique(messages.map(parseLookup));
96
+ return (0, utils_1.unique)(messages.map(parseLookup));
93
97
  };
98
+ exports.parseLogMissingLookups = parseLogMissingLookups;
94
99
  var mapTypeToId = function (nodes) { return nodes.reduce(function (prev, _a) {
95
100
  var type = _a["@type"], id = _a["@id"];
96
101
  prev[type] = prev[type] || [];
97
102
  prev[type].push(id);
98
103
  return prev;
99
104
  }, {}); };
100
- exports.formatForUpload = function (nodes, typeToId) {
105
+ var formatForUpload = function (nodes, typeToId) {
101
106
  if (typeToId === void 0) { typeToId = mapTypeToId(nodes); }
102
107
  return nodes.map(function (_a) {
103
108
  var _b;
104
109
  var type = _a["@type"], id = _a["@id"], node = __rest(_a, ['@type', '@id']);
105
110
  return type === schema_1.NodeType.Term
106
111
  ? { '@type': type, '@id': id }
107
- : utils_1.reduceUndefinedValues(__assign(__assign({}, (!id || ((_b = typeToId[type]) !== null && _b !== void 0 ? _b : []).includes(id) ? { type: type, id: id } : { '@type': type, '@id': id })), Object.fromEntries(Object.entries(node).map(function (_a) {
112
+ : (0, utils_1.reduceUndefinedValues)(__assign(__assign({}, (!id || ((_b = typeToId[type]) !== null && _b !== void 0 ? _b : []).includes(id) ? { type: type, id: id } : { '@type': type, '@id': id })), Object.fromEntries(Object.entries(node).map(function (_a) {
108
113
  var key = _a[0], value = _a[1];
109
- var newValue = schema_1.isExpandable(value)
114
+ var newValue = (0, schema_1.isExpandable)(value)
110
115
  ? Array.isArray(value)
111
- ? exports.formatForUpload(value, typeToId)
112
- : exports.formatForUpload([value], typeToId)[0]
116
+ ? (0, exports.formatForUpload)(value, typeToId)
117
+ : (0, exports.formatForUpload)([value], typeToId)[0]
113
118
  : value;
114
119
  return [key, newValue];
115
120
  }))));
116
121
  });
117
122
  };
123
+ exports.formatForUpload = formatForUpload;
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
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");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
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");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -50,22 +52,25 @@ var User = (function (_super) {
50
52
  return User;
51
53
  }(model_base_1.BaseModel));
52
54
  exports.User = User;
53
- exports.name = function (_a) {
55
+ var name = function (_a) {
54
56
  var firstName = _a.firstName, lastName = _a.lastName;
55
57
  return [firstName, lastName].filter(Boolean).join(' ');
56
58
  };
57
- exports.isAdmin = function (_a) {
59
+ exports.name = name;
60
+ var isAdmin = function (_a) {
58
61
  var role = _a.role;
59
62
  return role === UserRole.Admin;
60
63
  };
61
- exports.isReviewer = function (_a) {
64
+ exports.isAdmin = isAdmin;
65
+ var isReviewer = function (_a) {
62
66
  var role = _a.role;
63
67
  return [
64
68
  UserRole.Reviewer,
65
69
  UserRole.Admin
66
70
  ].includes(role);
67
71
  };
68
- exports.isDeveloper = function (_a) {
72
+ exports.isReviewer = isReviewer;
73
+ var isDeveloper = function (_a) {
69
74
  var role = _a.role;
70
75
  return [
71
76
  UserRole.Developer,
@@ -73,15 +78,19 @@ exports.isDeveloper = function (_a) {
73
78
  UserRole.Admin
74
79
  ].includes(role);
75
80
  };
76
- exports.contains = function (users, user) { return users.some(function (u) { return u.email === user.email; }); };
77
- exports.actorId = function (user) { return "" + (user._id || user.id).toString(); };
78
- var jsonLDContext = function (type, domain) { return domain + "/schema/" + type + ".jsonld"; };
81
+ exports.isDeveloper = isDeveloper;
82
+ var contains = function (users, user) { return users.some(function (u) { return u.email === user.email; }); };
83
+ exports.contains = contains;
84
+ var actorId = function (user) { return "".concat((user._id || user.id).toString()); };
85
+ exports.actorId = actorId;
86
+ var jsonLDContext = function (type, domain) { return "".concat(domain, "/schema/").concat(type, ".jsonld"); };
79
87
  var addIfDefined = function (key, value) {
80
88
  var _a;
81
89
  return !!value ? (_a = {}, _a[key] = value, _a) : {};
82
90
  };
83
- var profileData = function (user) { return (user.dataPrivate ? {} : __assign(__assign(__assign(__assign(__assign(__assign({ email: user.email, firstName: user.firstName, lastName: user.lastName, name: user.displayName || exports.name(user) }, addIfDefined('scopusID', user.scopusID)), addIfDefined('orcid', user.orcid)), addIfDefined('primaryInstitution', user.primaryInstitution)), addIfDefined('city', user.city)), addIfDefined('country', user.country ? { type: schema_1.NodeType.Term, name: user.country } : undefined)), addIfDefined('website', user.website ? { '@id': user.website } : undefined))); };
84
- exports.userToActor = function (user, domain) {
91
+ var profileData = function (user) { return (user.dataPrivate ? {} : __assign(__assign(__assign(__assign(__assign(__assign({ email: user.email, firstName: user.firstName, lastName: user.lastName, name: user.displayName || (0, exports.name)(user) }, addIfDefined('scopusID', user.scopusID)), addIfDefined('orcid', user.orcid)), addIfDefined('primaryInstitution', user.primaryInstitution)), addIfDefined('city', user.city)), addIfDefined('country', user.country ? { type: schema_1.NodeType.Term, name: user.country } : undefined)), addIfDefined('website', user.website ? { '@id': user.website } : undefined))); };
92
+ var userToActor = function (user, domain) {
85
93
  if (domain === void 0) { domain = 'https://hestia.earth'; }
86
- return (__assign({ '@context': jsonLDContext(schema_1.NodeType.Actor, domain), '@type': schema_1.NodeType.Actor, '@id': exports.actorId(user), dataPrivate: user.dataPrivate }, profileData(user)));
94
+ return (__assign({ '@context': jsonLDContext(schema_1.NodeType.Actor, domain), '@type': schema_1.NodeType.Actor, '@id': (0, exports.actorId)(user), dataPrivate: user.dataPrivate }, profileData(user)));
87
95
  };
96
+ exports.userToActor = userToActor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/api",
3
- "version": "0.18.9",
3
+ "version": "0.18.11",
4
4
  "description": "Hestia API definitions",
5
5
  "main": "dist/models.js",
6
6
  "typings": "dist/models.d.ts",
@@ -42,8 +42,8 @@
42
42
  "@hestia-earth/schema-validation": "^14.0.0",
43
43
  "@hestia-earth/utils": "^0.10.27",
44
44
  "@mendeley/api": "^10.0.2",
45
- "@sentry/node": "^6.18.2",
46
- "@sentry/tracing": "^6.18.2",
45
+ "@sentry/node": "^7.33.0",
46
+ "@sentry/tracing": "^7.33.0",
47
47
  "@slack/web-api": "^6.7.0",
48
48
  "@sokratis/passport-linkedin-oauth2": "^2.1.0",
49
49
  "@types/chai": "^4.3.0",
@@ -111,7 +111,7 @@
111
111
  "swagger-ui-express": "^4.3.0",
112
112
  "ts-node": "^10.9.1",
113
113
  "ts-node-dev": "^2.0.0",
114
- "typescript": "^3.9.10",
114
+ "typescript": "^4.9.4",
115
115
  "uid-generator": "^2.0.0",
116
116
  "winston": "^3.6.0"
117
117
  },