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 fill_1 = __importDefault(require("lodash/fill"));
|
8 | const flatten_1 = __importDefault(require("lodash/flatten"));
|
9 | const get_1 = __importDefault(require("lodash/get"));
|
10 | const zip_1 = __importDefault(require("lodash/zip"));
|
11 | const fieldPathToSchemaPath = (fieldPath) => {
|
12 | const newPath = zip_1.default(fill_1.default(fieldPath.split('.'), 'properties'), fieldPath.split('.'));
|
13 | return flatten_1.default(newPath).join('.');
|
14 | };
|
15 | exports.fieldPathToSchemaPath = fieldPathToSchemaPath;
|
16 |
|
17 | const schemaPointerToFieldPath = (jsonPointer) => {
|
18 | return jsonPointer
|
19 | .split('/')
|
20 | .slice(2)
|
21 | .filter(e => e !== 'properties')
|
22 | .join('.');
|
23 | };
|
24 | exports.schemaPointerToFieldPath = schemaPointerToFieldPath;
|
25 | const fieldPathToSchema = (schema, fieldPath) => {
|
26 | return get_1.default(schema, exports.fieldPathToSchemaPath(fieldPath));
|
27 | };
|
28 | exports.fieldPathToSchema = fieldPathToSchema;
|
29 |
|
\ | No newline at end of file |