schyma 1.0.0
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.
- package/LICENSE +201 -0
- package/README.md +80 -0
- package/dist/cjs/components/App.d.ts +9 -0
- package/dist/cjs/components/App.js +37 -0
- package/dist/cjs/components/App.js.map +1 -0
- package/dist/cjs/components/Code.d.ts +3 -0
- package/dist/cjs/components/Code.js +15 -0
- package/dist/cjs/components/Code.js.map +1 -0
- package/dist/cjs/components/Nodes.d.ts +14 -0
- package/dist/cjs/components/Nodes.js +178 -0
- package/dist/cjs/components/Nodes.js.map +1 -0
- package/dist/cjs/components/Panel.d.ts +12 -0
- package/dist/cjs/components/Panel.js +40 -0
- package/dist/cjs/components/Panel.js.map +1 -0
- package/dist/cjs/components/Tables.d.ts +8 -0
- package/dist/cjs/components/Tables.js +19 -0
- package/dist/cjs/components/Tables.js.map +1 -0
- package/dist/cjs/config.d.ts +0 -0
- package/dist/cjs/config.js +99 -0
- package/dist/cjs/config.js.map +1 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/scripts/buildtree.d.ts +34 -0
- package/dist/cjs/scripts/buildtree.js +181 -0
- package/dist/cjs/scripts/buildtree.js.map +1 -0
- package/dist/cjs/scripts/index.d.ts +1 -0
- package/dist/cjs/scripts/index.js +23 -0
- package/dist/cjs/scripts/index.js.map +1 -0
- package/dist/cjs/types/nodes.d.ts +24 -0
- package/dist/cjs/types/nodes.js +3 -0
- package/dist/cjs/types/nodes.js.map +1 -0
- package/dist/cjs/types.d.ts +24 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils/reusables.d.ts +6 -0
- package/dist/cjs/utils/reusables.js +111 -0
- package/dist/cjs/utils/reusables.js.map +1 -0
- package/dist/cjs/utils/types.d.ts +34 -0
- package/dist/cjs/utils/types.js +4 -0
- package/dist/cjs/utils/types.js.map +1 -0
- package/dist/esm/components/App.d.ts +9 -0
- package/dist/esm/components/App.js +34 -0
- package/dist/esm/components/App.js.map +1 -0
- package/dist/esm/components/Code.d.ts +3 -0
- package/dist/esm/components/Code.js +12 -0
- package/dist/esm/components/Code.js.map +1 -0
- package/dist/esm/components/Nodes.d.ts +14 -0
- package/dist/esm/components/Nodes.js +176 -0
- package/dist/esm/components/Nodes.js.map +1 -0
- package/dist/esm/components/Panel.d.ts +12 -0
- package/dist/esm/components/Panel.js +37 -0
- package/dist/esm/components/Panel.js.map +1 -0
- package/dist/esm/components/Tables.d.ts +8 -0
- package/dist/esm/components/Tables.js +16 -0
- package/dist/esm/components/Tables.js.map +1 -0
- package/dist/esm/components/worker.d.ts +1 -0
- package/dist/esm/components/worker.js +12 -0
- package/dist/esm/components/worker.js.map +1 -0
- package/dist/esm/config.d.ts +0 -0
- package/dist/esm/config.js +99 -0
- package/dist/esm/config.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/scripts/buildtree.d.ts +34 -0
- package/dist/esm/scripts/buildtree.js +178 -0
- package/dist/esm/scripts/buildtree.js.map +1 -0
- package/dist/esm/scripts/index.d.ts +1 -0
- package/dist/esm/scripts/index.js +19 -0
- package/dist/esm/scripts/index.js.map +1 -0
- package/dist/esm/types/nodes.d.ts +24 -0
- package/dist/esm/types/nodes.js +2 -0
- package/dist/esm/types/nodes.js.map +1 -0
- package/dist/esm/types.d.ts +24 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/reusables.d.ts +6 -0
- package/dist/esm/utils/reusables.js +102 -0
- package/dist/esm/utils/reusables.js.map +1 -0
- package/dist/esm/utils/types.d.ts +34 -0
- package/dist/esm/utils/types.js +4 -0
- package/dist/esm/utils/types.js.map +1 -0
- package/dist/esm/worker.d.ts +1 -0
- package/dist/esm/worker.js +12 -0
- package/dist/esm/worker.js.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
function Tables({ nodes, active }) {
|
|
6
|
+
return (react_1.default.createElement("div", { className: "panel_table-wrapper" },
|
|
7
|
+
react_1.default.createElement("table", null,
|
|
8
|
+
react_1.default.createElement("thead", null,
|
|
9
|
+
react_1.default.createElement("tr", null,
|
|
10
|
+
react_1.default.createElement("th", { scope: "" }, "Name"),
|
|
11
|
+
react_1.default.createElement("th", { scope: "" }, "Description"))),
|
|
12
|
+
react_1.default.createElement("tbody", null, nodes.map((node) => {
|
|
13
|
+
return react_1.default.createElement("tr", { key: node.data.id, className: `panel_table-wrapper_tbody ${(active === null || active === void 0 ? void 0 : active.data.label) === node.data.label ? "panel_table-wrapper_tbody_active" : ""}` },
|
|
14
|
+
react_1.default.createElement("th", { scope: "" }, node.data.label),
|
|
15
|
+
react_1.default.createElement("td", null, node.data.description));
|
|
16
|
+
})))));
|
|
17
|
+
}
|
|
18
|
+
exports.default = Tables;
|
|
19
|
+
//# sourceMappingURL=Tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tables.js","sourceRoot":"","sources":["../../../src/components/Tables.tsx"],"names":[],"mappings":";;;AAAA,0DAA0B;AAQ1B,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAY;IACvC,OAAO,CACH,uCAAK,SAAS,EAAC,qBAAqB;QAChC;YACI;gBACI;oBACI,sCAAI,KAAK,EAAC,EAAE,WAEP;oBACL,sCAAI,KAAK,EAAC,EAAE,kBAEP,CACJ,CACD;YACR,6CACK,KAAK,CAAC,GAAG,CAAC,CAAC,IAAU,EAAE,EAAE;gBACtB,OAAO,sCAAI,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,6BAA6B,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAC,KAAK,MAAK,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,EAAE,EAAE;oBACpJ,sCAAI,KAAK,EAAC,EAAE,IACP,IAAI,CAAC,IAAI,CAAC,KAAK,CACf;oBACL,0CACK,IAAI,CAAC,IAAI,CAAC,WAAW,CACrB,CACJ,CAAA;YACT,CAAC,CAAC,CACN,CACJ,CACN,CAEH,CAAA;AACH,CAAC;AAED,kBAAe,MAAM,CAAA"}
|
|
File without changes
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// const nodeClick = async (_event: React.MouseEvent, node: MyObject) => {
|
|
3
|
+
// if(nodeState[node.id]){
|
|
4
|
+
// const res:any = removeElementsByParent(nodes, node.id);
|
|
5
|
+
// setNodes([...res])
|
|
6
|
+
// setNodeState({});
|
|
7
|
+
// }else{
|
|
8
|
+
// const data = node.data
|
|
9
|
+
// const label = data.label;
|
|
10
|
+
// let props = data.properties;
|
|
11
|
+
// const newLabel = `${label}${data.parentLabel}`
|
|
12
|
+
// const nodeProps:any = {};
|
|
13
|
+
// if(refStorage[newLabel]){
|
|
14
|
+
// props = refStorage[newLabel].properties
|
|
15
|
+
// }else{
|
|
16
|
+
// if(label && refStorage[label]){
|
|
17
|
+
// if(label === data.parentLabel && refStorage[`${label}child`]){
|
|
18
|
+
// props = refStorage[`${label}child`].properties
|
|
19
|
+
// }else{
|
|
20
|
+
// props = refStorage[label].properties
|
|
21
|
+
// }
|
|
22
|
+
// }
|
|
23
|
+
// }
|
|
24
|
+
// if(props){
|
|
25
|
+
// for(let prop in props){
|
|
26
|
+
// if(refStorage[prop]){
|
|
27
|
+
// nodeProps[prop] = refStorage[prop]
|
|
28
|
+
// }else{
|
|
29
|
+
// nodeProps[prop] = props[prop]
|
|
30
|
+
// }
|
|
31
|
+
// }
|
|
32
|
+
// props = nodeProps
|
|
33
|
+
// }
|
|
34
|
+
// const children: any = [];
|
|
35
|
+
// for (const prop in props){
|
|
36
|
+
// const id = String(Math.floor(Math.random() * 1000000));
|
|
37
|
+
// const newProp = {
|
|
38
|
+
// id: id,
|
|
39
|
+
// data: {
|
|
40
|
+
// ...props[prop],
|
|
41
|
+
// label: prop,
|
|
42
|
+
// parent: node.id,
|
|
43
|
+
// parentLabel: label,
|
|
44
|
+
// relations: {
|
|
45
|
+
// ...data.relations,
|
|
46
|
+
// [node.id]: 'node'
|
|
47
|
+
// }
|
|
48
|
+
// },
|
|
49
|
+
// type: "output",
|
|
50
|
+
// }
|
|
51
|
+
// const checkNodeType = typeCheck(newProp.data)
|
|
52
|
+
// if(checkNodeType){
|
|
53
|
+
// newProp.type = "default"
|
|
54
|
+
// }
|
|
55
|
+
// children.push(newProp)
|
|
56
|
+
// }
|
|
57
|
+
// if(children){
|
|
58
|
+
// const itemChildren = [
|
|
59
|
+
// ...children.map((item: MyObject) => {
|
|
60
|
+
// return {
|
|
61
|
+
// id: item.id,
|
|
62
|
+
// data: item.data,
|
|
63
|
+
// style: { padding: 10, background: '#1E293B', color: 'white' },
|
|
64
|
+
// sourcePosition: 'right',
|
|
65
|
+
// targetPosition: 'left',
|
|
66
|
+
// position,
|
|
67
|
+
// draggable: false,
|
|
68
|
+
// }
|
|
69
|
+
// }),
|
|
70
|
+
// ]
|
|
71
|
+
// const newEdges:any = [
|
|
72
|
+
// ...edges,
|
|
73
|
+
// ...itemChildren.map((item) => {
|
|
74
|
+
// return {
|
|
75
|
+
// id: String(Math.floor(Math.random() * 1000000)),
|
|
76
|
+
// source: item?.data.parent,
|
|
77
|
+
// target: item?.id,
|
|
78
|
+
// animated: true,
|
|
79
|
+
// // style: { stroke: required && required.includes(item.data.label) ? '#EB38AB' : 'gray' },
|
|
80
|
+
// markerEnd: {
|
|
81
|
+
// type: MarkerType.ArrowClosed,
|
|
82
|
+
// },
|
|
83
|
+
// }
|
|
84
|
+
// }),
|
|
85
|
+
// ]
|
|
86
|
+
// const newNodes: any = nodes.concat(children)
|
|
87
|
+
// const { nodes: layoutedNodes, edges: layoutedEdges } = getLayoutedElements(newNodes, newEdges, 'LR')
|
|
88
|
+
// setNodes([...layoutedNodes])
|
|
89
|
+
// setEdges([...layoutedEdges])
|
|
90
|
+
// if (itemChildren.length > 3) {
|
|
91
|
+
// focusNode(itemChildren[3].position.x, itemChildren[3].position.y, 0.9)
|
|
92
|
+
// }
|
|
93
|
+
// }else{
|
|
94
|
+
// console.log('no children please')
|
|
95
|
+
// }
|
|
96
|
+
// setNodeState({...nodeState, [node.id]: 'node'})
|
|
97
|
+
// }
|
|
98
|
+
// }
|
|
99
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";AAEE,0EAA0E;AAC1E,4BAA4B;AAC5B,8DAA8D;AAC9D,yBAAyB;AACzB,wBAAwB;AACxB,WAAW;AACX,6BAA6B;AAC7B,gCAAgC;AAChC,mCAAmC;AACnC,qDAAqD;AACrD,gCAAgC;AAChC,gCAAgC;AAChC,gDAAgD;AAChD,aAAa;AACb,wCAAwC;AACxC,yEAAyE;AACzE,2DAA2D;AAC3D,iBAAiB;AACjB,iDAAiD;AACjD,YAAY;AACZ,UAAU;AACV,QAAQ;AAER,iBAAiB;AACjB,gCAAgC;AAChC,gCAAgC;AAChC,+CAA+C;AAC/C,iBAAiB;AACjB,0CAA0C;AAC1C,YAAY;AACZ,UAAU;AACV,0BAA0B;AAC1B,QAAQ;AACR,gCAAgC;AAChC,iCAAiC;AACjC,gEAAgE;AAChE,0BAA0B;AAC1B,kBAAkB;AAClB,kBAAkB;AAClB,4BAA4B;AAC5B,yBAAyB;AACzB,6BAA6B;AAC7B,gCAAgC;AAChC,yBAAyB;AACzB,iCAAiC;AACjC,gCAAgC;AAChC,cAAc;AACd,aAAa;AACb,0BAA0B;AAC1B,UAAU;AACV,sDAAsD;AACtD,2BAA2B;AAC3B,mCAAmC;AACnC,UAAU;AACV,+BAA+B;AAC/B,QAAQ;AACR,oBAAoB;AACpB,+BAA+B;AAC/B,gDAAgD;AAChD,oBAAoB;AACpB,2BAA2B;AAC3B,+BAA+B;AAC/B,6EAA6E;AAC7E,uCAAuC;AACvC,sCAAsC;AACtC,wBAAwB;AACxB,gCAAgC;AAChC,cAAc;AACd,cAAc;AACd,UAAU;AACV,+BAA+B;AAC/B,oBAAoB;AACpB,0CAA0C;AAC1C,qBAAqB;AACrB,+DAA+D;AAC/D,yCAAyC;AACzC,gCAAgC;AAChC,8BAA8B;AAC9B,yGAAyG;AACzG,2BAA2B;AAC3B,8CAA8C;AAC9C,iBAAiB;AACjB,cAAc;AACd,cAAc;AACd,UAAU;AACV,qDAAqD;AACrD,6GAA6G;AAC7G,qCAAqC;AACrC,qCAAqC;AACrC,uCAAuC;AACvC,iFAAiF;AACjF,UAAU;AACV,aAAa;AACb,0CAA0C;AAC1C,QAAQ;AACR,sDAAsD;AACtD,MAAM;AACN,IAAI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,mEAAqC;AAErC,kBAAe,aAAM,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
type TreeInterface = {
|
|
2
|
+
required: any;
|
|
3
|
+
examples: any;
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
parent: number;
|
|
7
|
+
description: string;
|
|
8
|
+
children: Array<TreeInterface>;
|
|
9
|
+
$ref?: string;
|
|
10
|
+
title: string;
|
|
11
|
+
};
|
|
12
|
+
type MyObject = {
|
|
13
|
+
[x: string]: any;
|
|
14
|
+
};
|
|
15
|
+
interface PropertiesInterface extends TreeInterface {
|
|
16
|
+
properties?: MyObject;
|
|
17
|
+
additionalProperties?: AdditionalProperties | Boolean;
|
|
18
|
+
patternProperties?: MyObject;
|
|
19
|
+
$id?: string;
|
|
20
|
+
allOf?: Array<PropertiesInterface>;
|
|
21
|
+
anyOf?: Array<PropertiesInterface>;
|
|
22
|
+
oneOf?: Array<PropertiesInterface>;
|
|
23
|
+
items?: any;
|
|
24
|
+
definitions?: any;
|
|
25
|
+
}
|
|
26
|
+
interface AdditionalProperties extends TreeInterface {
|
|
27
|
+
items?: Array<TreeInterface>;
|
|
28
|
+
$ref?: string;
|
|
29
|
+
allOf?: Array<TreeInterface>;
|
|
30
|
+
anyOf?: Array<TreeInterface>;
|
|
31
|
+
oneOf?: Array<TreeInterface>;
|
|
32
|
+
}
|
|
33
|
+
export default function buildTree(schemaObject: PropertiesInterface): Promise<TreeInterface[]>;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const reusables_1 = require("../utils/reusables");
|
|
5
|
+
let schema;
|
|
6
|
+
let tree = [];
|
|
7
|
+
function fetchExamples(ref) {
|
|
8
|
+
const data = (0, reusables_1.retrieveObj)(schema, ref);
|
|
9
|
+
if (data)
|
|
10
|
+
return data;
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
function buildFromChildren(object) {
|
|
14
|
+
const properties = buildProperties(object, object.id);
|
|
15
|
+
buildRoot(object, object.id, 'children', properties);
|
|
16
|
+
}
|
|
17
|
+
function extractProps(object, newProperty, parent) {
|
|
18
|
+
const obj = object.properties;
|
|
19
|
+
for (const property in obj) {
|
|
20
|
+
if (typeof obj[property] === 'object') {
|
|
21
|
+
newProperty[property] = obj[property];
|
|
22
|
+
newProperty[property].parent = parent;
|
|
23
|
+
newProperty[property].name = property;
|
|
24
|
+
newProperty[property].id = String(Math.floor(Math.random() * 1000000));
|
|
25
|
+
newProperty[property].children = [];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function extractPatternProps(object, newProperty, parent) {
|
|
30
|
+
const obj = object.patternProperties;
|
|
31
|
+
for (const property in obj) {
|
|
32
|
+
if (typeof obj[property] === 'object') {
|
|
33
|
+
newProperty[property] = obj[property];
|
|
34
|
+
newProperty[property].parent = parent;
|
|
35
|
+
newProperty[property].name = property;
|
|
36
|
+
newProperty[property].id = String(Math.floor(Math.random() * 1000000));
|
|
37
|
+
newProperty[property].children = [];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function extractAdditionalProps(object, newProperty, parent) {
|
|
42
|
+
const obj = object.additionalProperties;
|
|
43
|
+
const arrayProps = (obj === null || obj === void 0 ? void 0 : obj.oneOf) || (obj === null || obj === void 0 ? void 0 : obj.anyOf);
|
|
44
|
+
if (arrayProps) {
|
|
45
|
+
extractArrayProps(obj, newProperty, parent);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
extractProps(obj, newProperty, parent);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function extractArrayProps(object, newProperty, parent) {
|
|
52
|
+
var _a;
|
|
53
|
+
if (object.anyOf || object.allOf || object.oneOf) {
|
|
54
|
+
const arrayOfProps = object.allOf || object.oneOf || object.anyOf;
|
|
55
|
+
if (arrayOfProps) {
|
|
56
|
+
for (let i = 0; i < arrayOfProps.length; i++) {
|
|
57
|
+
if (arrayOfProps[i].$ref) {
|
|
58
|
+
const newRef = arrayOfProps[i]['$ref'].split('/').slice(-1)[0];
|
|
59
|
+
const title = newRef.split('.')[0];
|
|
60
|
+
newProperty[title] = arrayOfProps[i];
|
|
61
|
+
newProperty[title].parent = parent;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const children = arrayOfProps[i];
|
|
65
|
+
const patterns = children === null || children === void 0 ? void 0 : children.patternProperties;
|
|
66
|
+
const properties = children === null || children === void 0 ? void 0 : children.properties;
|
|
67
|
+
if (patterns) {
|
|
68
|
+
extractPatternProps(patterns, newProperty, parent);
|
|
69
|
+
}
|
|
70
|
+
if (properties) {
|
|
71
|
+
extractProps(children, newProperty, parent);
|
|
72
|
+
}
|
|
73
|
+
if ((_a = arrayOfProps[i]) === null || _a === void 0 ? void 0 : _a.oneOf) {
|
|
74
|
+
const title = object.name;
|
|
75
|
+
const a = arrayOfProps[i].oneOf;
|
|
76
|
+
for (let i = 0; i < a.length; i++) {
|
|
77
|
+
newProperty[title] = children.oneOf && children.oneOf[i];
|
|
78
|
+
newProperty[title].parent = parent;
|
|
79
|
+
newProperty[title].name = title;
|
|
80
|
+
newProperty[title].id = String(Math.floor(Math.random() * 1000000));
|
|
81
|
+
newProperty[title].children = [];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function extractItems(object, newProperty, parent) {
|
|
90
|
+
const items = object.items;
|
|
91
|
+
const arrayItems = items.oneOf || items.allOf || items.anyOf;
|
|
92
|
+
if (items.properties) {
|
|
93
|
+
extractProps(items, newProperty, parent);
|
|
94
|
+
}
|
|
95
|
+
if (arrayItems) {
|
|
96
|
+
extractArrayProps(items, newProperty, parent);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function buildProperties(object, parent) {
|
|
100
|
+
let newProperty = {};
|
|
101
|
+
if (object.properties) {
|
|
102
|
+
extractProps(object, newProperty, parent);
|
|
103
|
+
}
|
|
104
|
+
if (object.patternProperties) {
|
|
105
|
+
extractPatternProps(object, newProperty, parent);
|
|
106
|
+
}
|
|
107
|
+
if (object.additionalProperties && object.additionalProperties !== false) {
|
|
108
|
+
extractAdditionalProps(object, newProperty, parent);
|
|
109
|
+
}
|
|
110
|
+
if (object.items) {
|
|
111
|
+
extractItems(object, newProperty, parent);
|
|
112
|
+
}
|
|
113
|
+
if (!object.properties && !object.patternProperties && !object.additionalProperties) {
|
|
114
|
+
extractArrayProps(object, newProperty, parent);
|
|
115
|
+
}
|
|
116
|
+
return newProperty;
|
|
117
|
+
}
|
|
118
|
+
function iterateChildren(objChildren) {
|
|
119
|
+
for (let i = 0; i < objChildren.length; i++) {
|
|
120
|
+
if (objChildren[i]['$ref']) {
|
|
121
|
+
const res = fetchExamples(objChildren[i]['$ref']);
|
|
122
|
+
if (res === null || res === void 0 ? void 0 : res.description) {
|
|
123
|
+
objChildren[i].description = res.description;
|
|
124
|
+
}
|
|
125
|
+
if (res === null || res === void 0 ? void 0 : res.required) {
|
|
126
|
+
objChildren[i].required = res.required;
|
|
127
|
+
}
|
|
128
|
+
if (res === null || res === void 0 ? void 0 : res.examples) {
|
|
129
|
+
objChildren[i].examples = res.examples;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (objChildren[i].children.length <= 0) {
|
|
133
|
+
buildFromChildren(objChildren[i]);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function buildRoot(object, parentId, type, properties) {
|
|
138
|
+
if (type === 'initial') {
|
|
139
|
+
const properties = buildProperties(schema, parentId);
|
|
140
|
+
object.title = schema.title;
|
|
141
|
+
object.required = schema.required;
|
|
142
|
+
for (const property in properties) {
|
|
143
|
+
object.children.push(Object.assign(Object.assign({}, properties[property]), { parent: parentId, name: property, id: String(Math.floor(Math.random() * 1000000)), children: [] }));
|
|
144
|
+
}
|
|
145
|
+
const objChildren = object.children;
|
|
146
|
+
iterateChildren(objChildren);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
if (!object.children) {
|
|
150
|
+
object['children'] = [];
|
|
151
|
+
}
|
|
152
|
+
if (object.children.length <= 0) {
|
|
153
|
+
for (const property in properties) {
|
|
154
|
+
object.children.push(Object.assign(Object.assign({}, properties[property]), { parent: parentId || object.id, name: properties[property].title || property, id: properties[property].id || String(Math.floor(Math.random() * 1000000)), children: properties[property].children || [] }));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const objChildren = object.children;
|
|
158
|
+
iterateChildren(objChildren);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function buildTree(schemaObject) {
|
|
162
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
163
|
+
const parentLeaf = {
|
|
164
|
+
id: 1,
|
|
165
|
+
name: '',
|
|
166
|
+
parent: 0,
|
|
167
|
+
description: '',
|
|
168
|
+
children: [],
|
|
169
|
+
title: '',
|
|
170
|
+
$ref: '',
|
|
171
|
+
required: undefined,
|
|
172
|
+
examples: undefined,
|
|
173
|
+
};
|
|
174
|
+
schema = schemaObject;
|
|
175
|
+
tree[0] = parentLeaf;
|
|
176
|
+
buildRoot(tree[0], 1, 'initial', {});
|
|
177
|
+
return tree;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
exports.default = buildTree;
|
|
181
|
+
//# sourceMappingURL=buildtree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildtree.js","sourceRoot":"","sources":["../../../src/scripts/buildtree.ts"],"names":[],"mappings":";;;AAAA,kDAAgD;AAEhD,IAAI,MAA2B,CAAA;AAoC/B,IAAI,IAAI,GAAyB,EAAE,CAAA;AAEnC,SAAS,aAAa,CAAC,GAAW;IAChC,MAAM,IAAI,GAAG,IAAA,uBAAW,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACrC,IAAI,IAAI;QAAE,OAAO,IAAI,CAAA;IACrB,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,iBAAiB,CAAC,MAA2B;IACpD,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAA;IACrD,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,YAAY,CAAC,MAA2B,EAAE,WAAqB,EAAE,MAAc;IACtF,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAA;IAC7B,KAAK,MAAM,QAA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E,SAAS,EAAE,EAAE,CAAC,CAAA;QACpC,OAAO,IAAI,CAAA;IACb,CAAC;CAAA;AAhBD,4BAgBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const startBuild: (schema: any) => Promise<any>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startBuild = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// import { writeFileSync } from "fs";
|
|
6
|
+
// import { resolve } from "path";
|
|
7
|
+
const buildtree_js_1 = tslib_1.__importDefault(require("./buildtree.js"));
|
|
8
|
+
const startBuild = (schema) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
9
|
+
try {
|
|
10
|
+
const tree = (0, buildtree_js_1.default)(schema);
|
|
11
|
+
return tree;
|
|
12
|
+
// return writeFileSync(
|
|
13
|
+
// resolve(__dirname, `../configs`, `${version}.json`),
|
|
14
|
+
// JSON.stringify(trees)
|
|
15
|
+
// );
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
console.log(error);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
exports.startBuild = startBuild;
|
|
22
|
+
3;
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scripts/index.ts"],"names":[],"mappings":";;;;AAAA,sCAAsC;AACtC,kCAAkC;AAClC,0EAAuC;AAEhC,MAAM,UAAU,GAAG,CAAO,MAAW,EAAE,EAAE;IAC5C,IAAI;QACA,MAAM,IAAI,GAAQ,IAAA,sBAAS,EAAC,MAAM,CAAC,CAAC;QACpC,OAAO,IAAI,CAAA;QACX,wBAAwB;QACxB,2DAA2D;QAC3D,4BAA4B;QAC5B,KAAK;KACR;IAAC,OAAO,KAAK,EAAE;QACZ,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACtB;AACL,CAAC,CAAA,CAAA;AAXY,QAAA,UAAU,cAWtB;AAED,CAAC,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type NodeType = {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
parent: number;
|
|
5
|
+
description: string;
|
|
6
|
+
children: Array<Node>;
|
|
7
|
+
$ref?: string;
|
|
8
|
+
title: string;
|
|
9
|
+
label: string;
|
|
10
|
+
targetPosition?: string;
|
|
11
|
+
sourcePosition?: string;
|
|
12
|
+
position?: object;
|
|
13
|
+
data?: NodeType;
|
|
14
|
+
};
|
|
15
|
+
export type EdgeType = {
|
|
16
|
+
id: string;
|
|
17
|
+
source: string;
|
|
18
|
+
target: string;
|
|
19
|
+
label: string;
|
|
20
|
+
labelBgPadding: number[];
|
|
21
|
+
labelBgBorderRadius: number;
|
|
22
|
+
labelBgStyle: object;
|
|
23
|
+
markerEnd: object;
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../src/types/nodes.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type NodeType = {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
parent: number;
|
|
5
|
+
description: string;
|
|
6
|
+
children: Array<Node>;
|
|
7
|
+
$ref?: string;
|
|
8
|
+
title: string;
|
|
9
|
+
label: string;
|
|
10
|
+
targetPosition?: string;
|
|
11
|
+
sourcePosition?: string;
|
|
12
|
+
position?: object;
|
|
13
|
+
data?: NodeType;
|
|
14
|
+
};
|
|
15
|
+
export type EdgeType = {
|
|
16
|
+
id: string;
|
|
17
|
+
source: string;
|
|
18
|
+
target: string;
|
|
19
|
+
label: string;
|
|
20
|
+
labelBgPadding: number[];
|
|
21
|
+
labelBgBorderRadius: number;
|
|
22
|
+
labelBgStyle: object;
|
|
23
|
+
markerEnd: object;
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function resolveRef(ref: string, schema: any): Promise<JSONSchema>;
|
|
2
|
+
export declare function nameFromRef(string: string): string;
|
|
3
|
+
export declare function propMerge(schema: any): {};
|
|
4
|
+
export declare function arrayToProps(props: any): any;
|
|
5
|
+
export declare function removeElementsByParent(nodes: any, id: any): any;
|
|
6
|
+
export declare function retrieveObj(theObject: any, key: string | undefined): any;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.retrieveObj = exports.removeElementsByParent = exports.arrayToProps = exports.propMerge = exports.nameFromRef = exports.resolveRef = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const reference_resolver_1 = tslib_1.__importDefault(require("@json-schema-tools/reference-resolver"));
|
|
6
|
+
function resolveRef(ref, schema) {
|
|
7
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
8
|
+
const resolver = yield reference_resolver_1.default.resolve(ref, schema);
|
|
9
|
+
return resolver;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
exports.resolveRef = resolveRef;
|
|
13
|
+
function nameFromRef(string) {
|
|
14
|
+
const newRef = string.split('/').slice(-1)[0];
|
|
15
|
+
return newRef.split('.')[0];
|
|
16
|
+
}
|
|
17
|
+
exports.nameFromRef = nameFromRef;
|
|
18
|
+
function propMerge(schema) {
|
|
19
|
+
let mergedProps = {};
|
|
20
|
+
const { properties, patternProperties, additionalProperties, items, oneOf } = schema;
|
|
21
|
+
const arrWithObject = additionalProperties || items;
|
|
22
|
+
const arrExtractor = (items) => {
|
|
23
|
+
const props = arrayToProps(items);
|
|
24
|
+
mergedProps = Object.assign(Object.assign({}, mergedProps), props);
|
|
25
|
+
};
|
|
26
|
+
if (schema.patternProperties) {
|
|
27
|
+
mergedProps = Object.assign(Object.assign({}, mergedProps), patternProperties);
|
|
28
|
+
}
|
|
29
|
+
if (schema.properties) {
|
|
30
|
+
mergedProps = Object.assign(Object.assign({}, mergedProps), properties);
|
|
31
|
+
}
|
|
32
|
+
if (arrWithObject) {
|
|
33
|
+
if (arrWithObject.oneOf) {
|
|
34
|
+
arrExtractor(arrWithObject.oneOf);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (oneOf) {
|
|
38
|
+
arrExtractor(oneOf);
|
|
39
|
+
}
|
|
40
|
+
return mergedProps;
|
|
41
|
+
}
|
|
42
|
+
exports.propMerge = propMerge;
|
|
43
|
+
function arrayToProps(props) {
|
|
44
|
+
const propObj = {};
|
|
45
|
+
for (let i = 0; i < props.length; i++) {
|
|
46
|
+
if (props[i].$ref) {
|
|
47
|
+
const name = nameFromRef(props[i].$ref);
|
|
48
|
+
propObj[name] = props[i];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return propObj;
|
|
52
|
+
}
|
|
53
|
+
exports.arrayToProps = arrayToProps;
|
|
54
|
+
function removeElementsByParent(nodes, id) {
|
|
55
|
+
const result = nodes.filter((node) => {
|
|
56
|
+
const relations = node.data.relations;
|
|
57
|
+
if (relations) {
|
|
58
|
+
if (relations.hasOwnProperty(id)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return node;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return node;
|
|
66
|
+
});
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
exports.removeElementsByParent = removeElementsByParent;
|
|
70
|
+
function retrieveObj(theObject, key) {
|
|
71
|
+
var result = null;
|
|
72
|
+
if (theObject instanceof Array) {
|
|
73
|
+
for (var i = 0; i < theObject.length; i++) {
|
|
74
|
+
result = retrieveObj(theObject[i], key);
|
|
75
|
+
if (result) {
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
for (var prop in theObject) {
|
|
82
|
+
if (prop == key) {
|
|
83
|
+
return theObject[prop];
|
|
84
|
+
}
|
|
85
|
+
if (theObject[prop] instanceof Object ||
|
|
86
|
+
theObject[prop] instanceof Array) {
|
|
87
|
+
result = retrieveObj(theObject[prop], key);
|
|
88
|
+
if (result) {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
exports.retrieveObj = retrieveObj;
|
|
97
|
+
// export function typeCheck(data: any): boolean {
|
|
98
|
+
// switch (true) {
|
|
99
|
+
// case !!data.oneOf:
|
|
100
|
+
// case !!data.anyOf:
|
|
101
|
+
// case !!data.allOf:
|
|
102
|
+
// case !!data.items:
|
|
103
|
+
// case !! data.patternProperties:
|
|
104
|
+
// case data.additionalProperties !== undefined && data.additionalProperties !== true:
|
|
105
|
+
// case data.additionalItems !== undefined && data.additionalItems !== true:
|
|
106
|
+
// return true;
|
|
107
|
+
// default:
|
|
108
|
+
// return false;
|
|
109
|
+
// }
|
|
110
|
+
// }
|
|
111
|
+
//# sourceMappingURL=reusables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reusables.js","sourceRoot":"","sources":["../../../src/utils/reusables.ts"],"names":[],"mappings":";;;;AAAA,uGAA2D;AAG3D,SAAsB,UAAU,CAAC,GAAW,EAAE,MAAW;;QACvD,MAAM,QAAQ,GAAG,MAAM,4BAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QAClD,OAAO,QAAQ,CAAA;IACjB,CAAC;CAAA;AAHD,gCAGC;AAED,SAAgB,WAAW,CAAC,MAAc;IACxC,MAAM,MAAM,GAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,C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F;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AA1BD,kCA0BC;AAED,kDAAkD;AAClD,oBAAoB;AACpB,yBAAyB;AACzB,yBAAyB;AACzB,yBAAyB;AACzB,yBAAyB;AACzB,sCAAsC;AACtC,0FAA0F;AAC1F,gFAAgF;AAChF,qBAAqB;AACrB,eAAe;AACf,sBAAsB;AACtB,MAAM;AACN,IAAI"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
declare let schema: PropertiesInterface;
|
|
2
|
+
type TreeInterface = {
|
|
3
|
+
required: any;
|
|
4
|
+
examples: any;
|
|
5
|
+
id: number;
|
|
6
|
+
name: string;
|
|
7
|
+
parent: number;
|
|
8
|
+
description: string;
|
|
9
|
+
children: Array<TreeInterface>;
|
|
10
|
+
$ref?: string;
|
|
11
|
+
title: string;
|
|
12
|
+
};
|
|
13
|
+
type MyObject = {
|
|
14
|
+
[x: string]: any;
|
|
15
|
+
};
|
|
16
|
+
interface PropertiesInterface extends TreeInterface {
|
|
17
|
+
properties?: MyObject;
|
|
18
|
+
additionalProperties?: AdditionalProperties | Boolean;
|
|
19
|
+
patternProperties?: MyObject;
|
|
20
|
+
$id?: string;
|
|
21
|
+
allOf?: Array<PropertiesInterface>;
|
|
22
|
+
anyOf?: Array<PropertiesInterface>;
|
|
23
|
+
oneOf?: Array<PropertiesInterface>;
|
|
24
|
+
items?: any;
|
|
25
|
+
definitions?: any;
|
|
26
|
+
}
|
|
27
|
+
interface AdditionalProperties extends TreeInterface {
|
|
28
|
+
items?: Array<TreeInterface>;
|
|
29
|
+
$ref?: string;
|
|
30
|
+
allOf?: Array<TreeInterface>;
|
|
31
|
+
anyOf?: Array<TreeInterface>;
|
|
32
|
+
oneOf?: Array<TreeInterface>;
|
|
33
|
+
}
|
|
34
|
+
declare let tree: Array<TreeInterface>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":";AAAA,IAAI,MAA2B,CAAA;AAoC/B,IAAI,IAAI,GAAyB,EAAE,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { JSONSchema7Object } from "json-schema";
|
|
3
|
+
interface Default {
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
schema: JSONSchema7Object;
|
|
7
|
+
}
|
|
8
|
+
declare function Schyma({ title, description, schema }: Default): React.JSX.Element;
|
|
9
|
+
export default Schyma;
|