@@ -6,10 +6,10 @@ import * as stringToStream from 'string-to-stream';
66import { IHydraClient } from '../alcaeus' ;
77import * as Constants from '../Constants' ;
88import { JsonLd } from '../Constants' ;
9- import { IResourceGraph } from '../HydraResponse' ;
109import { forOwn } from '../LodashUtil' ;
1110import { ParserFactory } from '../ParserFactory' ;
1211import { IResourceFactory } from '../ResourceFactory' ;
12+ import { IResourceGraph , ResourceGraph } from '../ResourceGraph' ;
1313import { ApiDocumentation } from '../Resources' ;
1414import { IResource } from '../Resources/Resource' ;
1515import { IResponseWrapper } from '../ResponseWrapper' ;
@@ -105,7 +105,7 @@ async function flatten(json, url): Promise<object> {
105105function resourcify (
106106 createResource : ( obj , resources ) => IResource ,
107107 obj ,
108- resourcified : object ) {
108+ resourcified : IResourceGraph ) {
109109 if ( ( typeof obj === 'object' ) === false ) {
110110 return obj ;
111111 }
@@ -144,18 +144,13 @@ function resourcify(
144144}
145145
146146function processResources ( createResource : ( obj , resources ) => IResource , resources ) : IResourceGraph {
147- const resourcified = { } ;
147+ const resourcified = new ResourceGraph ( ) ;
148148 resources . forEach ( ( res ) => {
149- try {
150- res [ JsonLd . Id ] = new URL ( res [ JsonLd . Id ] ) . href ;
151- } catch ( e ) { }
152-
153149 resourcified [ res [ JsonLd . Id ] ] = res ;
154150 } ) ;
155151
156- resources . reduceRight ( ( acc : object , val ) => {
157- const id = val [ JsonLd . Id ] ;
158- acc [ id ] = createResource ( val , acc ) ;
152+ resources . reduceRight ( ( acc : ResourceGraph , val ) => {
153+ acc . add ( createResource ( val , acc ) ) ;
159154 return acc ;
160155 } , resourcified ) ;
161156
0 commit comments