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