src/type-registry.js
/**
 * Initializes the public Type Index Registry resource, updates
 * the profile with the initialized index, and returns the updated profile.
 * @method initTypeRegistryPublic
 * @param profile {SolidProfile} User's WebID profile
 * @param webClient {SolidWebClient}
 * @param [options] Options hashmap (see solid.web.solidRequest() function docs)
 * @return {Promise<SolidProfile>} Resolves with the updated profile instance.
 */
Initializes the public Type Index Registry resource, updates
the profile with the initialized index, and returns the updated profile.
Initializes the public Type Index Registry resource updates the profile with the initialized index and returns the updated profile .
function initTypeRegistryPublic (profile, webClient, options) {
  options = options || {}
  var rdf = webClient.rdf
  var ns = vocab(rdf)
  var registryContainerUri = profile.typeRegistryDefaultContainer()
  var webId = rdf.namedNode(profile.webId)
  var publicIndex = blankPublicTypeIndex(rdf)
  return webClient.post(registryContainerUri, publicIndex.data,
                        publicIndex.slug)
    .catch(function (err) {
      throw new Error('Could not create publicIndex document:', err)
    })
    .then(function (response) {
      publicIndex.uri = util.absoluteUrl(
        webUtil.hostname(registryContainerUri),
        response.url
      )
      var toAdd = [
        rdf.triple(webId, ns.solid('publicTypeIndex'),
          rdf.namedNode(publicIndex.uri))
      ]
      var toDel = []
      return webClient.patch(profile.webId, toDel, toAdd, options)
    })
    .catch(function (err) {
      console.log(err)
      throw new Error('Could not update profile with public index:', err)
    })
    .then(function (response) {
      profile.typeIndexListed = publicIndex
      return profile
    })
}
function initTypeRegistryPublic ( profile , webClient , options ) { options = options || { } var rdf = webClient . rdf var ns = vocab ( rdf ) var registryContainerUri = profile . typeRegistryDefaultContainer ( ) var webId = rdf . namedNode ( profile . webId ) var publicIndex = blankPublicTypeIndex ( rdf ) return webClient . post ( registryContainerUri , publicIndex . data , publicIndex . slug ) . catch ( function ( err ) { throw new Error ( 'Could not create publicIndex document:' , err ) } ) . then ( function ( response ) { publicIndex . uri = util . absoluteUrl ( webUtil . hostname ( registryContainerUri ) , response . url ) var toAdd = [ rdf . triple ( webId , ns . solid ( 'publicTypeIndex' ) , rdf . namedNode ( publicIndex . uri ) ) ] var toDel = [ ] return webClient . patch ( profile . webId , toDel , toAdd , options ) } ) . catch ( function ( err ) { console . log ( err ) throw new Error ( 'Could not update profile with public index:' , err ) } ) . then ( function ( response ) { profile . typeIndexListed = publicIndex return profile } ) }
Initializes the public Type Index Registry resource, updates
 the profile with the initialized index, and returns the updated profile.
Initializes the public Type Index Registry resource updates the profile with the initialized index and returns the updated profile .
// First, create the public Type Index Registry resource // Public type index resource created. Update the profile to link to it. // Profile successfully patched with a link to the created public index // It's safe to update this instance of profile // Finally, return the updated profile with type index loaded