src/type-registry.js
/**
 * Initializes the private Type Index Registry resource, updates
 * the profile with the initialized index, and returns the updated profile.
 * @method initTypeRegistryPrivate
 * @param profile {SolidProfile} User's WebID profile
 * @param [options] Options hashmap (see solid.web.solidRequest() function docs)
 * @return {Promise<SolidProfile>} Resolves with the updated profile instance.
 */
Initializes the private Type Index Registry resource, updates
the profile with the initialized index, and returns the updated profile.
@method initTypeRegistryPrivate
@param profile {SolidProfile} User's WebID profile
@param [options] Options hashmap  function docs)
@return {Promise} Resolves with the updated profile instance.
Initializes the private Type Index Registry resource updates the profile with the initialized index and returns the updated profile . @method initTypeRegistryPrivate @param profile { SolidProfile } User ' s WebID profile @param [ options ] Options hashmap function docs ) @return { Promise } Resolves with the updated profile instance .
function initTypeRegistryPrivate (profile, webClient, options) {
  options = options || {}
  var rdf = webClient.rdf
  var ns = vocab(rdf)
  var registryContainerUri = profile.typeRegistryDefaultContainer()
  var webId = rdf.namedNode(profile.webId)
  var privateIndex = blankPrivateTypeIndex(rdf)
  return webClient.post(registryContainerUri, privateIndex.data,
                        privateIndex.slug)
    .catch(function (err) {
      throw new Error('Could not create privateIndex document:', err)
    })
    .then(function (response) {
      privateIndex.uri = util.absoluteUrl(
        webUtil.hostname(registryContainerUri),
        response.url
      )
      var toAdd = [
        rdf.triple(webId, ns.solid('privateTypeIndex'),
          rdf.namedNode(privateIndex.uri))
      ]
      var toDel = []
      return webClient.patch(profile.privateProfileUri(), toDel, toAdd, options)
    })
    .catch(function (err) {
      throw new Error('Could not update profile with private index:' + err)
    })
    .then(function (response) {
      profile.typeIndexUnlisted = privateIndex
      return profile
    })
}
function initTypeRegistryPrivate ( profile , webClient , options ) { options = options || { } var rdf = webClient . rdf var ns = vocab ( rdf ) var registryContainerUri = profile . typeRegistryDefaultContainer ( ) var webId = rdf . namedNode ( profile . webId ) var privateIndex = blankPrivateTypeIndex ( rdf ) return webClient . post ( registryContainerUri , privateIndex . data , privateIndex . slug ) . catch ( function ( err ) { throw new Error ( 'Could not create privateIndex document:' , err ) } ) . then ( function ( response ) { privateIndex . uri = util . absoluteUrl ( webUtil . hostname ( registryContainerUri ) , response . url ) var toAdd = [ rdf . triple ( webId , ns . solid ( 'privateTypeIndex' ) , rdf . namedNode ( privateIndex . uri ) ) ] var toDel = [ ] return webClient . patch ( profile . privateProfileUri ( ) , toDel , toAdd , options ) } ) . catch ( function ( err ) { throw new Error ( 'Could not update profile with private index:' + err ) } ) . then ( function ( response ) { profile . typeIndexUnlisted = privateIndex return profile } ) }
Initializes the private Type Index Registry resource, updates
 the profile with the initialized index, and returns the updated profile.
Initializes the private Type Index Registry resource updates the profile with the initialized index and returns the updated profile .
// First, create the private Type Index Registry resource // Private type index resource created. // Update the private profile (preferences) to link to it. // Note: this PATCH will actually create a private profile if it doesn't // already exist. // Profile successfully patched with a link to the created private index // It's safe to update this instance of profile // Finally, return the updated profile with type index loaded