@hestia-earth/schema-convert 30.3.2 → 30.5.0

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/csv-pivot.d.ts CHANGED
@@ -3,6 +3,7 @@ export declare const toCsv: (nodes: any[], keys?: string[], excludeKeys?: string
3
3
  /**
4
4
  * CSV format for data processing.
5
5
  *
6
+ * @pram schemas Schema definitions to use for pivoting.
6
7
  * @param nodes List of nodes to convert.
7
8
  * @returns CSV content formatted with pivoted blank nodes.
8
9
  */
package/csv-pivot.js CHANGED
@@ -7,12 +7,10 @@ var parseValue = function (value) {
7
7
  var result = (0, utils_1.convertValue)(value);
8
8
  return typeof result === undefined || result === null ? '' : result.toString();
9
9
  };
10
- var withType = function (nodes) {
11
- return nodes.map(function (node) {
12
- var _a;
13
- return (_a = {}, _a["".concat(node['@type'][0].toLowerCase()).concat(node['@type'].substring(1))] = node, _a);
14
- });
15
- };
10
+ var withType = function (nodes) { return nodes.map(function (node) {
11
+ var _a;
12
+ return (_a = {}, _a[(0, utils_1.uncapitalize)(node['@type'] || node.type)] = node, _a);
13
+ }); };
16
14
  var toCsv = function (nodes, keys, excludeKeys) {
17
15
  if (excludeKeys === void 0) { excludeKeys = utils_1.omitKeys; }
18
16
  return (0, utils_1.jsonToCsv)(withType(nodes), {
@@ -26,6 +24,7 @@ exports.toCsv = toCsv;
26
24
  /**
27
25
  * CSV format for data processing.
28
26
  *
27
+ * @pram schemas Schema definitions to use for pivoting.
29
28
  * @param nodes List of nodes to convert.
30
29
  * @returns CSV content formatted with pivoted blank nodes.
31
30
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/schema-convert",
3
- "version": "30.3.2",
3
+ "version": "30.5.0",
4
4
  "description": "HESTIA Schema Converters",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
package/utils.d.ts CHANGED
@@ -19,4 +19,5 @@ export declare const daysInYear: (year: number) => 366 | 365;
19
19
  export declare const convertValue: (value: any) => any;
20
20
  export declare const findDuplicates: (values: string[]) => string[];
21
21
  export declare const findNonDuplicates: (values: string[]) => string[];
22
+ export declare const uncapitalize: (text: string) => string;
22
23
  export declare const jsonToCsv: (values: Record<string, any>[], options?: Json2CsvOptions) => string;
package/utils.js CHANGED
@@ -36,7 +36,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
36
36
  return to.concat(ar || Array.prototype.slice.call(from));
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.jsonToCsv = exports.findNonDuplicates = exports.findDuplicates = exports.convertValue = exports.daysInYear = exports.daysBefore = exports.diffInDays = exports.keyToLabel = exports.ellipsis = exports.reduceUndefinedValues = exports.nonEmptyNode = exports.nonEmptyValue = exports.isEmpty = exports.isNumber = exports.isBoolean = exports.isIri = exports.isExpandable = exports.omit = exports.childkey = exports.parentKey = exports.omitKeys = void 0;
39
+ exports.jsonToCsv = exports.uncapitalize = exports.findNonDuplicates = exports.findDuplicates = exports.convertValue = exports.daysInYear = exports.daysBefore = exports.diffInDays = exports.keyToLabel = exports.ellipsis = exports.reduceUndefinedValues = exports.nonEmptyNode = exports.nonEmptyValue = exports.isEmpty = exports.isNumber = exports.isBoolean = exports.isIri = exports.isExpandable = exports.omit = exports.childkey = exports.parentKey = exports.omitKeys = void 0;
40
40
  var json_2_csv_1 = require("json-2-csv");
41
41
  var get = require('lodash.get');
42
42
  var unset = require('lodash.unset');
@@ -45,7 +45,6 @@ exports.omitKeys = __spreadArray([
45
45
  'schemaVersion',
46
46
  'dataPrivate'
47
47
  ], __read(['bibliography', 'site', 'cycle', 'impactAssessment', 'defaultSource', 'source'].flatMap(function (k) { return [
48
- "".concat(k, ".id"),
49
48
  "".concat(k, ".type"),
50
49
  "".concat(k, ".@type")
51
50
  ]; })), false);
@@ -162,6 +161,8 @@ var findDuplicates = function (values) { return duplicates(count(values)); };
162
161
  exports.findDuplicates = findDuplicates;
163
162
  var findNonDuplicates = function (values) { return nonDuplicates(count(values)); };
164
163
  exports.findNonDuplicates = findNonDuplicates;
164
+ var uncapitalize = function (text) { return "".concat(text[0].toLowerCase()).concat(text.substring(1)); };
165
+ exports.uncapitalize = uncapitalize;
165
166
  /**
166
167
  * Move every item on the same row.
167
168
  *