@mat3ra/esse 2024.2.19-0 → 2024.2.19-1
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.
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
export interface CacheObject {
|
|
2
|
+
[key: string]: CacheObject | CacheObject[];
|
|
3
|
+
}
|
|
2
4
|
export declare class JSONInclude {
|
|
3
|
-
JSON_INCLUDE_CACHE:
|
|
5
|
+
JSON_INCLUDE_CACHE: CacheObject;
|
|
4
6
|
/**
|
|
5
7
|
* Extracts file name(path) from the include statement.
|
|
6
8
|
* @param value string to extract the file name from.
|
|
@@ -11,10 +13,10 @@ export declare class JSONInclude {
|
|
|
11
13
|
* @param obj Object to traverse.
|
|
12
14
|
* @param dirpath directory from which `obj` is obtained. Include statements are relative to `obj` path.
|
|
13
15
|
*/
|
|
14
|
-
_walkObjectToInclude(obj:
|
|
16
|
+
_walkObjectToInclude(obj: CacheObject | CacheObject[], dirpath: string): void;
|
|
15
17
|
/**
|
|
16
18
|
* Resolves `include` statements.
|
|
17
19
|
* @param filePath file to parse.
|
|
18
20
|
*/
|
|
19
|
-
parseIncludeStatements(filePath: string):
|
|
21
|
+
parseIncludeStatements(filePath: string): CacheObject[];
|
|
20
22
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mat3ra/esse",
|
|
3
|
-
"version": "2024.2.19-
|
|
3
|
+
"version": "2024.2.19-1",
|
|
4
4
|
"description": "Mat3ra's Excellent Source of Schemas and Examples (ESSE) for Digital Materials R&D",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepublishOnly": "rm -rf lib; npm run transpile",
|
|
7
|
-
"transpile": "tsc
|
|
7
|
+
"transpile": "tsc && BUILD_ASSETS=true BUILD_PATH='./lib/js' node build_schemas.js",
|
|
8
8
|
"transpile-and-build-assets": "npm run transpile && ts-node compile_ts.ts",
|
|
9
9
|
"build:assets": "node build_schemas.js",
|
|
10
10
|
"build:js-and-python-modules": "BUILD_PYTHON_MODULES=true node build_schemas.js",
|
|
@@ -30,10 +30,25 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/Exabyte-io/esse",
|
|
32
32
|
"devDependencies": {
|
|
33
|
+
"@exabyte-io/eslint-config": "^2023.8.29-1",
|
|
33
34
|
"@types/js-yaml": "^4.0.9",
|
|
34
35
|
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
|
35
36
|
"@typescript-eslint/parser": "^5.9.1",
|
|
36
37
|
"chai": "4.3.4",
|
|
38
|
+
"eslint": "^7.32.0",
|
|
39
|
+
"eslint-config-airbnb": "^19.0.2",
|
|
40
|
+
"eslint-config-prettier": "^8.5.0",
|
|
41
|
+
"eslint-import-resolver-exports": "^1.0.0-beta.5",
|
|
42
|
+
"eslint-import-resolver-meteor": "^0.4.0",
|
|
43
|
+
"eslint-import-resolver-node": "^0.3.9",
|
|
44
|
+
"eslint-plugin-import": "^2.25.3",
|
|
45
|
+
"eslint-plugin-jsdoc": "^37.1.0",
|
|
46
|
+
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
47
|
+
"eslint-plugin-mui-path-imports": "0.0.15",
|
|
48
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
49
|
+
"eslint-plugin-react": "^7.30.0",
|
|
50
|
+
"eslint-plugin-react-hooks": "^4.3.0",
|
|
51
|
+
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
37
52
|
"husky": "^7.0.4",
|
|
38
53
|
"lint-staged": "^12.1.2",
|
|
39
54
|
"mocha": "^9.2.0",
|
|
@@ -54,27 +69,12 @@
|
|
|
54
69
|
"@babel/preset-typescript": "^7.22.5",
|
|
55
70
|
"@babel/register": "^7.16.0",
|
|
56
71
|
"@babel/runtime-corejs3": "7.16.8",
|
|
57
|
-
"@exabyte-io/eslint-config": "^2023.8.29-1",
|
|
58
72
|
"@tsconfig/node14": "^14.1.0",
|
|
59
73
|
"@tsconfig/node20": "^20.1.2",
|
|
60
74
|
"@types/chai": "^4.3.11",
|
|
61
75
|
"@types/json-schema-merge-allof": "^0.6.5",
|
|
62
76
|
"@types/mocha": "^10.0.6",
|
|
63
77
|
"ajv": "8.12.0",
|
|
64
|
-
"eslint": "^7.32.0",
|
|
65
|
-
"eslint-config-airbnb": "^19.0.2",
|
|
66
|
-
"eslint-config-prettier": "^8.5.0",
|
|
67
|
-
"eslint-import-resolver-exports": "^1.0.0-beta.5",
|
|
68
|
-
"eslint-import-resolver-meteor": "^0.4.0",
|
|
69
|
-
"eslint-import-resolver-node": "^0.3.9",
|
|
70
|
-
"eslint-plugin-import": "^2.25.3",
|
|
71
|
-
"eslint-plugin-jsdoc": "^37.1.0",
|
|
72
|
-
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
73
|
-
"eslint-plugin-mui-path-imports": "0.0.15",
|
|
74
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
75
|
-
"eslint-plugin-react": "^7.30.0",
|
|
76
|
-
"eslint-plugin-react-hooks": "^4.3.0",
|
|
77
|
-
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
78
78
|
"js-yaml": "^4.1.0",
|
|
79
79
|
"json-schema": "^0.4.0",
|
|
80
80
|
"json-schema-deref-sync": "0.14.0",
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
|
|
4
|
-
import { AnyObject } from "../esse/types";
|
|
5
4
|
import { isInstanceOf, safeParseJSON } from "../utils/common";
|
|
6
5
|
import { INCLUDE_KEY, INCLUDE_VALUE_REGEX, OBJECT_ONLY } from "./settings";
|
|
7
6
|
|
|
7
|
+
export interface CacheObject {
|
|
8
|
+
[key: string]: CacheObject | CacheObject[];
|
|
9
|
+
}
|
|
10
|
+
|
|
8
11
|
export class JSONInclude {
|
|
9
|
-
JSON_INCLUDE_CACHE:
|
|
12
|
+
JSON_INCLUDE_CACHE: CacheObject = {};
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* Extracts file name(path) from the include statement.
|
|
@@ -24,7 +27,7 @@ export class JSONInclude {
|
|
|
24
27
|
* @param obj Object to traverse.
|
|
25
28
|
* @param dirpath directory from which `obj` is obtained. Include statements are relative to `obj` path.
|
|
26
29
|
*/
|
|
27
|
-
_walkObjectToInclude(obj:
|
|
30
|
+
_walkObjectToInclude(obj: CacheObject | CacheObject[], dirpath: string) {
|
|
28
31
|
if (isInstanceOf(obj, "Array")) {
|
|
29
32
|
for (let i = 0; i < obj.length; i++) {
|
|
30
33
|
if (isInstanceOf(obj[i], "Object") || isInstanceOf(obj[i], "Array")) {
|
|
@@ -60,7 +63,7 @@ export class JSONInclude {
|
|
|
60
63
|
* @param filePath file to parse.
|
|
61
64
|
*/
|
|
62
65
|
parseIncludeStatements(filePath: string) {
|
|
63
|
-
const data:
|
|
66
|
+
const data: CacheObject[] = safeParseJSON(fs.readFileSync(filePath, "utf8"));
|
|
64
67
|
if (OBJECT_ONLY && !isInstanceOf(data, "Object")) {
|
|
65
68
|
throw new Error(
|
|
66
69
|
"The JSON file being included should always be a dict rather than a list",
|