Skip to content

Commit a48d84f

Browse files
authored
Merge pull request #44 from Exabyte-io/chore/SOF-6505
chore/SOF-6505
2 parents 108ee28 + 374cbcf commit a48d84f

23 files changed

+943
-52
lines changed

package-lock.json

+116-43
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
"./utils": "./dist/utils/index.js",
2323
"./constants": "./dist/constants.js",
2424
"./math": "./dist/math.js",
25+
"./JSONSchemasInterface": "./dist/JSONSchemasInterface.js",
2526
"./dist/context": "./dist/context/index.js",
2627
"./dist/entity": "./dist/entity/index.js",
2728
"./dist/utils": "./dist/utils/index.js",
2829
"./dist/constants": "./dist/constants.js",
29-
"./dist/math": "./dist/math.js"
30+
"./dist/math": "./dist/math.js",
31+
"./dist/JSONSchemasInterface": "./dist/JSONSchemasInterface.js"
3032
},
3133
"files": [
3234
"/dist",
@@ -48,12 +50,15 @@
4850
"@babel/preset-react": "7.16.7",
4951
"@babel/register": "^7.16.0",
5052
"@babel/runtime-corejs3": "7.16.8",
51-
"@exabyte-io/esse.js": "2023.5.29-0",
53+
"@exabyte-io/esse.js": "git+https://github.com/Exabyte-io/esse.git#b4bbdad0cdb4f3417b51cbb420eace2bfbb7b38a",
54+
"ajv": "4.1.7",
5255
"crypto-js": "^4.1.1",
56+
"js-yaml": "^4.1.0",
5357
"json-schema-merge-allof": "^0.8.1",
5458
"lodash": "^4.17.21",
5559
"mathjs": "^3.9.0",
5660
"mixwith": "^0.1.1",
61+
"nunjucks": "^3.2.4",
5762
"underscore": "^1.13.3",
5863
"underscore.string": "^3.3.4",
5964
"uuid": "8.3.2"

src/JSONSchemasInterface.js

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { schemas } from "@exabyte-io/esse.js/schemas";
2+
import Ajv from "ajv";
23
import mergeAllOf from "json-schema-merge-allof";
34

45
const schemasCache = new Map();
@@ -105,4 +106,15 @@ export class JSONSchemasInterface {
105106
});
106107
});
107108
}
109+
110+
/**
111+
* Create validation function for schema with schemaId
112+
* @param {string} schemaId - id of JSON schema from ESSE
113+
* @param {Object} options - Options to pass through to Ajv object
114+
* @return {ValidateFunction<unknown>}
115+
*/
116+
static resolveJsonValidator(schemaId, options = {}) {
117+
const ajv = new Ajv(options);
118+
return ajv.compile(this.schemaById(schemaId));
119+
}
108120
}

src/utils/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ import {
2828
removeCommentsFromSourceCode,
2929
removeEmptyLinesFromString,
3030
removeNewLinesAndExtraSpaces,
31+
renderTextWithSubstitutes,
3132
toFixedLocale,
3233
} from "./str";
3334
import { mapTree } from "./tree";
3435
import { containsEncodedComponents } from "./url";
3536
import { getUUID } from "./uuid";
37+
import { JsYamlAllSchemas, JsYamlTypes } from "./yaml";
3638

3739
export {
3840
compareEntitiesInOrderedSetForSorting,
@@ -73,4 +75,7 @@ export {
7375
mapTree,
7476
getSchemaWithDependencies,
7577
mergeTerminalNodes,
78+
JsYamlTypes,
79+
JsYamlAllSchemas,
80+
renderTextWithSubstitutes,
7681
};

0 commit comments

Comments
 (0)