UNPKG

1.16 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6exports.fieldPathToSchema = exports.schemaPointerToFieldPath = exports.fieldPathToSchemaPath = void 0;
7const get_1 = __importDefault(require("lodash/get"));
8const zip_1 = __importDefault(require("lodash/zip"));
9const fieldPathToSchemaPath = (fieldPath) => {
10 return (0, zip_1.default)(fieldPath.split('.').fill('properties'), fieldPath.split('.')).flat().join('.');
11};
12exports.fieldPathToSchemaPath = fieldPathToSchemaPath;
13// Assumption: used only for jsonPointer returned from traverse
14const schemaPointerToFieldPath = (jsonPointer) => {
15 return jsonPointer
16 .split('/')
17 .slice(2)
18 .filter(e => e !== 'properties')
19 .join('.');
20};
21exports.schemaPointerToFieldPath = schemaPointerToFieldPath;
22const fieldPathToSchema = (schema, fieldPath) => {
23 return (0, get_1.default)(schema, (0, exports.fieldPathToSchemaPath)(fieldPath));
24};
25exports.fieldPathToSchema = fieldPathToSchema;
26//# sourceMappingURL=Util.js.map
\No newline at end of file