@@ -11,46 +11,43 @@ export default class DocusaurusTransformer implements CalmTemplateTransformer {
1111 getTransformedModel ( calmJson : string ) {
1212 const calmSchema : CalmCoreSchema = JSON . parse ( calmJson ) ;
1313 const architecture : Architecture = CalmCore . fromJson ( calmSchema ) ;
14-
15- const relationships = architecture . relationships ;
1614 const graph = new CalmRelationshipGraph ( architecture . relationships ) ;
1715
1816 const nodes = architecture . nodes . map ( node => ( {
17+ ...node ,
1918 id : node . uniqueId ,
2019 title : node . name ,
21- name : node . name ,
22- slug : node . uniqueId , // Generate slug
2320 description : node . description || 'No description available.' ,
2421 nodeType : node . nodeType || 'unknown' ,
25- controls : node . controls ,
26- interfaces : node . interfaces ,
27- runAs : node . runAs ,
28- dataClassification : node . dataClassification ,
2922 relatedRelationships : graph . getRelatedRelationships ( node . uniqueId ) ,
3023 relatedNodes : graph . getRelatedNodes ( node . uniqueId )
3124 } ) ) ;
3225
3326 const flows = architecture . flows . map ( flow => {
3427 const transformedTransitions = flow . transitions . map ( ( transition : CalmFlowTransition ) => ( {
28+ ...transition ,
3529 relationshipId : transition . relationshipUniqueId ,
36- sequenceNumber : transition . sequenceNumber ,
37- summary : transition . summary ,
38- direction : transition . direction ,
3930 source : this . getSourceFromRelationship ( transition . relationshipUniqueId ) ,
4031 target : this . getTargetFromRelationship ( transition . relationshipUniqueId )
4132 } ) ) ;
4233
4334 return {
35+ ...flow ,
4436 title : flow . name ,
4537 id : flow . uniqueId ,
46- slug : flow . uniqueId ,
47- name : flow . name ,
48- description : flow . description ,
49- transitions : transformedTransitions ,
50- controls : flow . controls
38+ transitions : transformedTransitions
5139 } ;
5240 } ) ;
5341
42+ const relationships = architecture . relationships . map ( rel => ( {
43+ ...rel ,
44+ id : rel . uniqueId ,
45+ title : rel . uniqueId
46+ } ) ) ;
47+
48+ const metadata = architecture . metadata ;
49+
50+
5451 const controlRequirements : Record < string , { id :string , content :string , domain :string } [ ] > = { } ;
5552
5653 // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -62,10 +59,9 @@ export default class DocusaurusTransformer implements CalmTemplateTransformer {
6259 if ( ! controlRequirements [ id ] ) {
6360 controlRequirements [ id ] = [ ] ;
6461 controlRequirements [ id ] . push ( {
65- id : id ,
62+ id,
6663 content : requirement ,
6764 domain : control . controlId
68-
6965 } ) ;
7066 }
7167
@@ -75,18 +71,17 @@ export default class DocusaurusTransformer implements CalmTemplateTransformer {
7571
7672 const controlConfigurations : Record < string , { id :string , name :string , schema :string , description :string , domain : string , scope : string , appliedTo : string , content : string } [ ] > = { } ;
7773
78-
79- // Collect control requirements and configurations from nodes, flows, and relationships
8074 const addControlConfigurationToTable = ( controls : CalmControl [ ] , scope : string , appliedTo : string ) => {
8175 controls . forEach ( control => {
8276 control . requirements . forEach ( detail => {
8377 const configuration = detail . controlConfigUrl ;
84- if ( configuration [ 'control-id' ] ) {
85- if ( ! controlConfigurations [ configuration [ 'control-id' ] ] ) {
86- controlConfigurations [ configuration [ 'control-id' ] ] = [ ] ;
78+ const id = configuration [ 'control-id' ] ;
79+ if ( id ) {
80+ if ( ! controlConfigurations [ id ] ) {
81+ controlConfigurations [ id ] = [ ] ;
8782 }
88- controlConfigurations [ configuration [ 'control-id' ] ] . push ( {
89- id : configuration [ 'control-id' ] ,
83+ controlConfigurations [ id ] . push ( {
84+ id,
9085 name : configuration [ 'name' ] ,
9186 schema : configuration [ '$schema' ] ,
9287 description : configuration [ 'description' ] ,
@@ -115,7 +110,6 @@ export default class DocusaurusTransformer implements CalmTemplateTransformer {
115110 addControlRequirementToTable ( flow . controls , 'Flow' , flow . uniqueId ) ;
116111 } ) ;
117112
118-
119113 const groupedByDomainRequirements : Record < string , { id : string ; content : string ; domain : string } [ ] > = { } ;
120114
121115 Object . values ( controlRequirements ) . forEach ( requirements => {
@@ -127,7 +121,6 @@ export default class DocusaurusTransformer implements CalmTemplateTransformer {
127121 } ) ;
128122 } ) ;
129123
130-
131124 const groupedByDomainConfigurations : Record < string , { id :string , name :string , schema :string , description :string , domain : string , scope : string , appliedTo : string , content : string } [ ] > = { } ;
132125
133126 Object . values ( controlConfigurations ) . forEach ( controlConfigurations => {
@@ -139,8 +132,6 @@ export default class DocusaurusTransformer implements CalmTemplateTransformer {
139132 } ) ;
140133 } ) ;
141134
142-
143-
144135 const controls = Object . entries ( controlConfigurations ) . flatMap ( ( [ id , configurations ] ) =>
145136 configurations . map ( config => ( {
146137 id,
@@ -155,14 +146,16 @@ export default class DocusaurusTransformer implements CalmTemplateTransformer {
155146 } ) )
156147 ) ;
157148
158- const C4model = new C4Model ( architecture ) ;
149+ const C4model = new C4Model ( architecture ) ;
159150
160151 return {
161152 nodes,
153+ relationships,
162154 flows,
163155 controls,
164156 controlReqs,
165157 C4model,
158+ metadata,
166159 docs : {
167160 nodes,
168161 flows,
@@ -172,7 +165,8 @@ export default class DocusaurusTransformer implements CalmTemplateTransformer {
172165 groupedByDomainRequirements,
173166 groupedByDomainConfigurations,
174167 C4model,
175- controlConfigurations
168+ controlConfigurations,
169+ metadata
176170 }
177171 } ;
178172 }
@@ -208,14 +202,11 @@ export default class DocusaurusTransformer implements CalmTemplateTransformer {
208202 } ;
209203 }
210204
211-
212-
213-
214205 private getSourceFromRelationship ( relationshipId : string ) : string {
215206 return relationshipId . split ( '-uses-' ) [ 0 ] ;
216207 }
217208
218209 private getTargetFromRelationship ( relationshipId : string ) : string {
219210 return relationshipId . split ( '-uses-' ) . slice ( - 1 ) [ 0 ] ;
220211 }
221- }
212+ }
0 commit comments