@hestia-earth/api 0.24.39 → 0.24.41

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.
@@ -196,17 +196,16 @@ var filenameWithoutExt = function (filepath) {
196
196
  };
197
197
  exports.filenameWithoutExt = filenameWithoutExt;
198
198
  exports.validPathChars = 'A-Za-z\\d\\-_';
199
+ var rstripChar = function (value) { return (value.length > 1 ? value.replace(/(\.|\_)$/g, '') : value); };
199
200
  var replaceInvalidChars = function (value) {
200
201
  var folder = (0, exports.folderFromPath)(value);
201
202
  var newFilename = value
202
- ? (0, exports.filenameWithoutExt)(value)
203
- .replace(/(\.|\_)$/g, '')
203
+ ? rstripChar(rstripChar((0, exports.filenameWithoutExt)(value))
204
204
  .replace(new RegExp("[^".concat(exports.validPathChars, "]"), 'g'), '_')
205
205
  .replace(new RegExp(Object.values(SupportedExtensions)
206
206
  .map(function (v) { return "(_".concat(v, ")"); })
207
207
  .join('|'), 'g'), '')
208
- .replace(/[\_]{2,}/g, '_')
209
- .replace(/(\.|\_)$/g, '')
208
+ .replace(/[\_]{2,}/g, '_'))
210
209
  : null;
211
210
  return newFilename
212
211
  ? (value === null || value === void 0 ? void 0 : value.includes('.'))
@@ -18,5 +18,5 @@ export declare const parseLogMissingLookups: (data: string) => {
18
18
  }[];
19
19
  export declare const formatForUpload: (nodes: any[], typeToId?: {
20
20
  [type: string]: string[];
21
- }, schemas?: import("@hestia-earth/json-schema").definitions) => any;
21
+ }) => any;
22
22
  export declare const setPrivate: ({ source, defaultSource, ...node }: any) => any;
@@ -26,7 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.setPrivate = exports.formatForUpload = exports.parseLogMissingLookups = exports.paramToNodeType = exports.nodeTypeToParam = exports.pathWithState = exports.allowedDataStates = exports.dataStatesTypeMapping = exports.DataState = exports.blankNodeTypes = void 0;
27
27
  var schema_1 = require("@hestia-earth/schema");
28
28
  var utils_1 = require("@hestia-earth/utils");
29
- var json_schema_1 = require("@hestia-earth/json-schema");
30
29
  var model_1 = require("../../files/model/model");
31
30
  exports.blankNodeTypes = Object.values(schema_1.SchemaType).filter(function (t) { return !(0, schema_1.isTypeNode)(t); });
32
31
  var DataState;
@@ -99,26 +98,19 @@ var mapTypeToId = function (nodes) {
99
98
  return prev;
100
99
  }, {});
101
100
  };
102
- var formatForUpload = function (nodes, typeToId, schemas) {
101
+ var formatForUpload = function (nodes, typeToId) {
103
102
  if (typeToId === void 0) { typeToId = mapTypeToId(nodes); }
104
- if (schemas === void 0) { schemas = (0, json_schema_1.loadSchemas)(); }
105
103
  return nodes.map(function (_a) {
106
104
  var _b;
107
105
  var type = _a["@type"], id = _a["@id"], node = __rest(_a, ['@type', '@id']);
108
106
  return type === schema_1.NodeType.Term
109
107
  ? { '@type': type, '@id': id }
110
- : (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)
111
- .filter(function (_a) {
112
- var _b, _c, _d;
113
- var key = _a[0];
114
- return !((_d = (_c = (_b = schemas === null || schemas === void 0 ? void 0 : schemas[type]) === null || _b === void 0 ? void 0 : _b.properties) === null || _c === void 0 ? void 0 : _c[key]) === null || _d === void 0 ? void 0 : _d.internal);
115
- })
116
- .map(function (_a) {
108
+ : (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) {
117
109
  var key = _a[0], value = _a[1];
118
110
  var newValue = (0, schema_1.isExpandable)(value)
119
111
  ? Array.isArray(value)
120
- ? (0, exports.formatForUpload)(value, typeToId, schemas)
121
- : (0, exports.formatForUpload)([value], typeToId, schemas)[0]
112
+ ? (0, exports.formatForUpload)(value, typeToId)
113
+ : (0, exports.formatForUpload)([value], typeToId)[0]
122
114
  : value;
123
115
  return [key, newValue];
124
116
  }))), true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/api",
3
- "version": "0.24.39",
3
+ "version": "0.24.41",
4
4
  "description": "Hestia API definitions",
5
5
  "main": "dist/models.js",
6
6
  "typings": "dist/models.d.ts",