File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed
packages/graph-schema-utils/src/formatters/json Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @neo4j/graph-schema-utils " : patch
3+ ---
4+
5+ exported json struct functions and types
Original file line number Diff line number Diff line change @@ -49,6 +49,11 @@ export function toJson(
4949 schema : GraphSchema ,
5050 space : string | number | undefined = undefined
5151) {
52+ const out = toJsonStruct ( schema ) ;
53+ return JSON . stringify ( out , null , space ) ;
54+ }
55+
56+ export function toJsonStruct ( schema : GraphSchema ) : RootSchemaJsonStruct {
5257 const labels = schema . nodeLabels
5358 . sort ( ( a , b ) => ( a . $id < b . $id ? - 1 : 1 ) )
5459 . map ( nodeLabel . extract ) ;
@@ -90,11 +95,15 @@ export function toJson(
9095 } ,
9196 } ,
9297 } ;
93- return JSON . stringify ( out , null , space ) ;
98+ return out ;
9499}
95100
96101export function fromJson ( schema : string ) : GraphSchema {
97102 const schemaJson = JSON . parse ( schema ) as RootSchemaJsonStruct ;
103+ return fromJsonStruct ( schemaJson ) ;
104+ }
105+
106+ export function fromJsonStruct ( schemaJson : RootSchemaJsonStruct ) : GraphSchema {
98107 const { graphSchema } = schemaJson . graphSchemaRepresentation ;
99108 const labels = graphSchema . nodeLabels . map ( nodeLabel . create ) ;
100109 const relationshipTypes = graphSchema . relationshipTypes . map (
Original file line number Diff line number Diff line change 1+ export * from "./types.js" ;
12export { toJson , fromJson , VERSION } from "./extensions.js" ;
You can’t perform that action at this time.
0 commit comments