src/app-registry.js
/**
 * Initializes the private App Registry resource, updates
 * the profile with the initialized registry, and returns the updated profile.
 * @method initAppRegistryPrivate
 * @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 App Registry resource, updates
the profile with the initialized registry, and returns the updated profile.
@method initAppRegistryPrivate
@param profile {SolidProfile} User's WebID profile
@param [options={}] Options hashmap
function docs)
@return {Promise} Resolves with the updated profile instance.
Initializes the private App Registry resource updates the profile with the initialized registry and returns the updated profile . @method initAppRegistryPrivate @param profile { SolidProfile } User ' s WebID profile @param [ options = {} ] Options hashmap function docs ) @return { Promise } Resolves with the updated profile instance .
function initAppRegistryPrivate (profile, webClient, options) {
  options = options || {}
  var rdf = profile.rdf
  var ns = vocab(rdf)
  var registryContainerUri = profile.appRegistryDefaultContainer()
  var webId = rdf.namedNode(profile.webId)
  var registry = blankPrivateAppRegistry(rdf)
  return webClient.post(registryContainerUri, registry.data,
    registry.slug)
    .catch(function (err) {
      throw new Error('Could not create private registry document:', err)
    })
    .then(function (response) {
      registry.uri = util.absoluteUrl(webUtil.hostname(registryContainerUri),
        response.url)
      var toAdd = [
        rdf.triple(webId, ns.solid('privateAppRegistry'),
          rdf.namedNode(registry.uri))
      ]
      var toDel = []
      return webClient.patch(profile.privateProfileUri(), toDel, toAdd,
        options)
    })
    .catch(function (err) {
      throw new Error('Could not update profile with private registry:' + err)
    })
    .then(function (response) {
      profile.appRegistryUnlisted = registry
      return profile
    })
}
function initAppRegistryPrivate ( profile , webClient , options ) { options = options || { } var rdf = profile . rdf var ns = vocab ( rdf ) var registryContainerUri = profile . appRegistryDefaultContainer ( ) var webId = rdf . namedNode ( profile . webId ) var registry = blankPrivateAppRegistry ( rdf ) return webClient . post ( registryContainerUri , registry . data , registry . slug ) . catch ( function ( err ) { throw new Error ( 'Could not create private registry document:' , err ) } ) . then ( function ( response ) { registry . uri = util . absoluteUrl ( webUtil . hostname ( registryContainerUri ) , response . url ) var toAdd = [ rdf . triple ( webId , ns . solid ( 'privateAppRegistry' ) , rdf . namedNode ( registry . uri ) ) ] var toDel = [ ] return webClient . patch ( profile . privateProfileUri ( ) , toDel , toAdd , options ) } ) . catch ( function ( err ) { throw new Error ( 'Could not update profile with private registry:' + err ) } ) . then ( function ( response ) { profile . appRegistryUnlisted = registry return profile } ) }
Initializes the private App Registry resource, updates
 the profile with the initialized registry, and returns the updated profile.
Initializes the private App Registry resource updates the profile with the initialized registry and returns the updated profile .
// First, create the private App Registry resource // Private registry 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 registry // It's safe to update this instance of profile // Finally, return the updated profile with registry loaded