@hestia-earth/pipeline-utils 0.13.16 → 0.13.17

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/api.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { NodeType } from '@hestia-earth/schema';
1
+ import { NodeType, SchemaType } from '@hestia-earth/schema';
2
2
  export declare const isEnabled: () => boolean;
3
3
  export declare const getNode: (id: string, type: NodeType) => Promise<any>;
4
- export declare const formatOriginalId: (id: string) => string;
4
+ export declare const formatOriginalId: (type: SchemaType, id: string) => string;
5
+ export declare const nodeUniqueIdFilepath: (folder: string, type: SchemaType, originalId: string) => string;
package/dist/api.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatOriginalId = exports.getNode = exports.isEnabled = void 0;
3
+ exports.nodeUniqueIdFilepath = exports.formatOriginalId = exports.getNode = exports.isEnabled = void 0;
4
+ const schema_1 = require("@hestia-earth/schema");
4
5
  const axios_1 = require("axios");
5
6
  const apiUrl = () => process.env.API_URL;
6
7
  const apiAccessToken = () => process.env.API_ACCESS_TOKEN;
@@ -18,6 +19,10 @@ const getNode = async (id, type) => {
18
19
  }
19
20
  };
20
21
  exports.getNode = getNode;
21
- const formatOriginalId = (id) => id.toLowerCase().replace(/[^\w\-\.]+/g, '');
22
+ const excludeType = [schema_1.SchemaType.Term];
23
+ const isTypeExcluded = (type) => excludeType.includes(type);
24
+ const formatOriginalId = (type, id) => isTypeExcluded(type) ? id : id.toLowerCase().replace(/[^\w\-\.]+/g, '');
22
25
  exports.formatOriginalId = formatOriginalId;
26
+ const nodeUniqueIdFilepath = (folder, type, originalId) => [folder, type, `${(0, exports.formatOriginalId)(type, originalId)}.txt`].join('/');
27
+ exports.nodeUniqueIdFilepath = nodeUniqueIdFilepath;
23
28
  //# sourceMappingURL=api.js.map
package/dist/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"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gB,EAAE,UAAkB,EAAE,EAAE,CAC3F,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAA,wBAAgB,EAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAD3D,QAAA,oBAAoB,wBACuC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/pipeline-utils",
3
- "version": "0.13.16",
3
+ "version": "0.13.17",
4
4
  "description": "Utilities for running pipelines",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
package/src/api.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { NodeType } from '@hestia-earth/schema';
1
+ import { NodeType, SchemaType } from '@hestia-earth/schema';
2
2
  import axios from 'axios';
3
3
 
4
4
  const apiUrl = () => process.env.API_URL;
@@ -25,7 +25,24 @@ export const getNode = async (id: string, type: NodeType) => {
25
25
  }
26
26
  };
27
27
 
28
+ const excludeType = [SchemaType.Term];
29
+ const isTypeExcluded = (type: SchemaType) => excludeType.includes(type);
30
+
28
31
  /**
29
32
  * Formats the id used when loading exsting `@id`.
33
+ *
34
+ * Remove anything but: letters, numbers, dashes and dots.
35
+ */
36
+ export const formatOriginalId = (type: SchemaType, id: string) =>
37
+ isTypeExcluded(type) ? id : id.toLowerCase().replace(/[^\w\-\.]+/g, '');
38
+
39
+ /**
40
+ * Path of the file containing the node unique `@id`.
41
+ *
42
+ * @param folder The folder containing the upload.
43
+ * @param type The `type` of the Node.
44
+ * @param originalId The `id` used for upload.
45
+ * @returns
30
46
  */
31
- export const formatOriginalId = (id: string) => id.toLowerCase().replace(/[^\w\-\.]+/g, '');
47
+ export const nodeUniqueIdFilepath = (folder: string, type: SchemaType, originalId: string) =>
48
+ [folder, type, `${formatOriginalId(type, originalId)}.txt`].join('/');