nodejs-nomer 1.3.8 → 1.3.9

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.
@@ -14,12 +14,24 @@ jobs:
14
14
  contents: read
15
15
  id-token: write
16
16
  steps:
17
- - uses: actions/checkout@v4
18
- - uses: actions/setup-node@v3
17
+ - uses: actions/checkout@v5
18
+ - uses: actions/setup-node@v4
19
19
  with:
20
- node-version: '21.x'
20
+ node-version: '21.x'
21
21
  registry-url: 'https://registry.npmjs.org'
22
22
  - run: npm ci
23
- - run: npm publish
23
+ - name: Run build process
24
+ run: npm run build
25
+ - name: Verify dist folder exists
26
+ run: |
27
+ if [! -d "dist" ]; then
28
+ echo "X dist folder not found after build!"
29
+ ls -la
30
+ exit 1
31
+ fi
32
+ echo "OK dist folder content:"
33
+ ls -la dist/
34
+ - name: Publish to npm
35
+ run: npm publish --provenance --access public
24
36
  env:
25
37
  NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
package/dist/index.js ADDED
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Nomer = void 0;
7
+ var _utils = require("./utils");
8
+ var _result = _interopRequireDefault(require("./result"));
9
+ var _propertiesFile = require("properties-file");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
12
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
13
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
15
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
16
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
17
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
18
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
19
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
20
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
21
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
22
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
23
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
24
+ var Nomer = exports.Nomer = /*#__PURE__*/function () {
25
+ function Nomer() {
26
+ var propertiesPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
27
+ var echoOpt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
28
+ _classCallCheck(this, Nomer);
29
+ _defineProperty(this, "propertiesPath", null);
30
+ _defineProperty(this, "echoOpt", "");
31
+ this.propertiesPath = propertiesPath;
32
+ this.echoOpt = echoOpt;
33
+ }
34
+
35
+ /**
36
+ * Show version
37
+ * @returns string
38
+ */
39
+ return _createClass(Nomer, [{
40
+ key: "version",
41
+ value: function version() {
42
+ var res = (0, _utils.runNomer)((0, _utils.getNomerSimpleCmd)());
43
+ return res;
44
+ }
45
+ }, {
46
+ key: "clean",
47
+ value: function clean() {
48
+ var res = (0, _utils.runNomer)((0, _utils.getNomerSimpleCmd)("clean", false, this.getPropertiesPath()));
49
+ return res;
50
+ }
51
+ }, {
52
+ key: "inputSchema",
53
+ value: function inputSchema() {
54
+ var res = (0, _utils.runNomer)((0, _utils.getNomerSimpleCmd)("input-schema", false, this.getPropertiesPath()));
55
+ return res;
56
+ }
57
+ }, {
58
+ key: "outputSchema",
59
+ value: function outputSchema() {
60
+ var res = (0, _utils.runNomer)((0, _utils.getNomerSimpleCmd)("output-schema", false, this.getPropertiesPath()));
61
+ return res;
62
+ }
63
+ }, {
64
+ key: "properties",
65
+ value: function properties() {
66
+ var res = (0, _utils.runNomer)((0, _utils.getNomerSimpleCmd)("properties", false, this.getPropertiesPath()));
67
+ return res;
68
+ }
69
+ }, {
70
+ key: "matcher",
71
+ value: function matcher() {
72
+ var outputFormat = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "tsv";
73
+ var verbose = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
74
+ var res = (0, _utils.runNomer)((0, _utils.getNomerSimpleCmd)("matchers", verbose, null, outputFormat));
75
+ return res;
76
+ }
77
+ }, {
78
+ key: "validateTerm",
79
+ value: function validateTerm() {
80
+ var filepath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
81
+ var res = (0, _utils.runNomer)((0, _utils.getNomerValidateCmd)(filepath, "validate-term-link", this.getPropertiesPath()));
82
+ return res;
83
+ }
84
+ }, {
85
+ key: "replace",
86
+ value: function replace() {
87
+ var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
88
+ var matcher = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "globi-taxon-cache";
89
+ var res = (0, _utils.runNomer)((0, _utils.getNomerMatchCmd)(query, "replace", matcher, this.getPropertiesPath(), null, this.echoOpt));
90
+ return res;
91
+ }
92
+ }, {
93
+ key: "append",
94
+ value: function append() {
95
+ var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
96
+ var matcher = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "globi-taxon-cache";
97
+ var outputFormat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "tsv";
98
+ var res = (0, _utils.runNomer)((0, _utils.getNomerMatchCmd)(query, "append", matcher, this.getPropertiesPath(), outputFormat, this.echoOpt), query);
99
+ return res;
100
+ }
101
+ }, {
102
+ key: "appendAsync",
103
+ value: function appendAsync() {
104
+ var matcher = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "globi-taxon-cache";
105
+ var outputFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "tsv";
106
+ return (0, _utils.runNomerAsync)((0, _utils.getNomerMatchCmd)(null, "append", matcher, this.getPropertiesPath(), outputFormat, this.echoOpt));
107
+ }
108
+ }, {
109
+ key: "getPropertiesPath",
110
+ value: function getPropertiesPath() {
111
+ return this.propertiesPath;
112
+ }
113
+ }, {
114
+ key: "toJson",
115
+ value: function toJson(result) {
116
+ return _result["default"].json(result);
117
+ }
118
+ }, {
119
+ key: "toArray",
120
+ value: function toArray(result) {
121
+ var columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
122
+ return _result["default"].tsv(result, columns);
123
+ }
124
+ }, {
125
+ key: "toObject",
126
+ value: function toObject(result) {
127
+ var content = this.properties(this.getPropertiesPath());
128
+ var properties = (0, _propertiesFile.getProperties)(content);
129
+ var schemaInput = JSON.parse(properties["nomer.schema.input"]).map(function (i) {
130
+ return i.type + 'Input';
131
+ });
132
+ var schemaAppend = JSON.parse(properties["nomer.append.schema.output"]).map(function (i) {
133
+ return i.type;
134
+ });
135
+ return _result["default"].tsv(result, [].concat(_toConsumableArray(schemaInput), ["matchType"], _toConsumableArray(schemaAppend)));
136
+ }
137
+ }]);
138
+ }();
package/dist/result.js ADDED
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
9
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
10
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
12
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
13
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
14
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
15
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
16
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
17
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
19
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
+ var Result = exports["default"] = /*#__PURE__*/function () {
21
+ function Result() {
22
+ _classCallCheck(this, Result);
23
+ }
24
+ return _createClass(Result, null, [{
25
+ key: "json",
26
+ value: function json(result) {
27
+ var arr = [];
28
+ result.split("\n").forEach(function (e) {
29
+ return arr.push(JSON.parse(e));
30
+ });
31
+ return arr;
32
+ }
33
+ }, {
34
+ key: "tsv",
35
+ value: function tsv(result) {
36
+ var columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
37
+ var arr = [];
38
+ result.split('\n').forEach(function (line) {
39
+ arr.push(line.split('\t'));
40
+ });
41
+ return columns ? arr.map(function (v) {
42
+ return Object.assign.apply(Object, _toConsumableArray(columns.map(function (k, i) {
43
+ return _defineProperty({}, k, v[i]);
44
+ })));
45
+ }) : arr;
46
+ }
47
+ }]);
48
+ }();
package/dist/utils.js ADDED
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.runNomerAsync = exports.runNomer = exports.getNomerValidateCmd = exports.getNomerSimpleCmd = exports.getNomerMatchCmd = void 0;
7
+ var _require = require('child_process'),
8
+ execSync = _require.execSync,
9
+ spawn = _require.spawn;
10
+ var getNomerValidateCmd = exports.getNomerValidateCmd = function getNomerValidateCmd() {
11
+ var filepath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
12
+ var cmd = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "validate-term";
13
+ var properties = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
14
+ if (filepath === "") {
15
+ throw new Exception("Filepath cannot be empty string");
16
+ }
17
+ var nomerCmd = "curl -L ".concat(filepath, " | nomer ").concat(cmd);
18
+ if (properties) {
19
+ nomerCmd = "".concat(nomerCmd, " -p ").concat(properties);
20
+ }
21
+ return nomerCmd;
22
+ };
23
+ var getNomerMatchCmd = exports.getNomerMatchCmd = function getNomerMatchCmd() {
24
+ var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
25
+ var cmd = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "append";
26
+ var matcher = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "globi-taxon-cache";
27
+ var properties = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
28
+ var outputFormat = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
29
+ var echoOpt = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : "-e";
30
+ var nomerCmd = "";
31
+ if (query) {
32
+ nomerCmd = "echo ".concat(echoOpt, " '").concat(query, "' | ");
33
+ }
34
+ nomerCmd = "".concat(nomerCmd, "nomer ").concat(cmd, " ").concat(matcher);
35
+ if (properties) {
36
+ nomerCmd = "".concat(nomerCmd, " -p ").concat(properties);
37
+ }
38
+ if (outputFormat) {
39
+ nomerCmd = "".concat(nomerCmd, " -o ").concat(outputFormat);
40
+ }
41
+ return nomerCmd;
42
+ };
43
+ var getNomerSimpleCmd = exports.getNomerSimpleCmd = function getNomerSimpleCmd() {
44
+ var cmd = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "version";
45
+ var verbose = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
46
+ var properties = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
47
+ var outputFormat = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
48
+ var nomerCmd = "nomer ".concat(cmd);
49
+ if (properties) {
50
+ nomerCmd = "".concat(nomerCmd, " -p ").concat(properties);
51
+ }
52
+ if (outputFormat) {
53
+ nomerCmd = "".concat(nomerCmd, " -o ").concat(outputFormat);
54
+ }
55
+ if (verbose) {
56
+ nomerCmd = "".concat(nomerCmd, " -v");
57
+ }
58
+ return nomerCmd;
59
+ };
60
+ var runNomer = exports.runNomer = function runNomer(nomerCmd) {
61
+ try {
62
+ var result = execSync(nomerCmd, {
63
+ maxBuffer: 4096 * 4096
64
+ }).toString();
65
+ if (result) {
66
+ return result.trimEnd();
67
+ }
68
+ } catch (error) {
69
+ console.log("Error running nomer cmd: " + error.message);
70
+ return null;
71
+ }
72
+ };
73
+ var runNomerAsync = exports.runNomerAsync = function runNomerAsync(nomerCmd) {
74
+ var nomerCmdArr = nomerCmd.split(/\s+/);
75
+ var p = spawn(nomerCmdArr[0], nomerCmdArr.slice(1), {
76
+ // maxBuffer: 4096 * 4096
77
+ shell: true
78
+ });
79
+ return p;
80
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodejs-nomer",
3
- "version": "1.3.8",
3
+ "version": "1.3.9",
4
4
  "description": "NodeJS wrapper for nomer",
5
5
  "bin": {
6
6
  "nomer": "./bin/nomer"
@@ -36,4 +36,4 @@
36
36
  "dependencies": {
37
37
  "properties-file": "^3.5.1"
38
38
  }
39
- }
39
+ }