src/type-registry.js
/**
 * Registers a given RDF class in the user's type index registries, so that
 * other applications can discover it.
 * Note: If the relevant type index registry does not exist, it will be created.
 * @method registerType
 * @param profile {SolidProfile} Loaded WebID profile
 * @param rdfClass {rdf.NamedNode} Type to register in the index.
 * @param location {String} Absolute URI to the location you want the class
 *   registered to. (Example: Registering Address books in
 *   `https://example.com/contacts/`)
 * @param [locationType='container'] {String} Either 'instance' or 'container',
 *   defaults to 'container'
 * @param [isListed=false] {Boolean} Whether to register in a listed or unlisted
 *   index). Defaults to `false` (unlisted).
 * @param webClient {SolidWebClient}
 * @return {Promise<SolidProfile>} Resolves with the updated profile.
 */
Registers a given RDF class in the user's type index registries, so that
other applications can discover it.
Note: If the relevant type index registry does not exist, it will be created.
@method registerType
@param profile {SolidProfile} Loaded WebID profile
@param rdfClass {rdf.NamedNode} Type to register in the index.
@param location {String} Absolute URI to the location you want the class
registered to.
Registers a given RDF class in the user ' s type index registries so that other applications can discover it . Note : If the relevant type index registry does not exist it will be created . @method registerType @param profile { SolidProfile } Loaded WebID profile @param rdfClass { rdf . NamedNode } Type to register in the index . @param location { String } Absolute URI to the location you want the class registered to .
function registerType (profile, rdfClass, location, locationType, isListed,
                       webClient) {
  if (!profile) {
    throw new Error('No profile provided')
  }
  if (!profile.isLoaded) {
    throw new Error('Profile is not loaded')
  }
  if (!rdfClass || !location) {
    throw new Error('Type registration requires type class and location')
  }
  locationType = locationType || 'container'
  if (locationType !== 'container' && locationType !== 'instance') {
    throw new Error('Invalid location type')
  }
  return loadTypeRegistry(profile, webClient)
    .then(function (profile) {
      if (isListed && !profile.hasTypeRegistryPublic()) {
        return initTypeRegistryPublic(profile, webClient)
      }
      if (!isListed && !profile.hasTypeRegistryPrivate()) {
        return initTypeRegistryPrivate(profile, webClient)
      }
      return profile
    })
    .then(function (profile) {
      return addToTypeIndex(profile, rdfClass, location, webClient,
        locationType, isListed)
    })
}
function registerType ( profile , rdfClass , location , locationType , isListed , webClient ) { if ( ! profile ) { throw new Error ( 'No profile provided' ) } if ( ! profile . isLoaded ) { throw new Error ( 'Profile is not loaded' ) } if ( ! rdfClass || ! location ) { throw new Error ( 'Type registration requires type class and location' ) } locationType = locationType || 'container' if ( locationType !== 'container' && locationType !== 'instance' ) { throw new Error ( 'Invalid location type' ) } return loadTypeRegistry ( profile , webClient ) . then ( function ( profile ) { if ( isListed && ! profile . hasTypeRegistryPublic ( ) ) { return initTypeRegistryPublic ( profile , webClient ) } if ( ! isListed && ! profile . hasTypeRegistryPrivate ( ) ) { return initTypeRegistryPrivate ( profile , webClient ) } return profile } ) . then ( function ( profile ) { return addToTypeIndex ( profile , rdfClass , location , webClient , locationType , isListed ) } ) }
Registers a given RDF class in the user's type index registries, so that
 other applications can discover it.
Registers a given RDF class in the user ' s type index registries so that other applications can discover it .
// make sure type registry is loaded // Public type registry is needed, but doesn't exist. Create it. // Private type registry is needed, but doesn't exist. Create it. // Relevant type registry exists, proceed // Made sure the relevant type registry exists, and can now add to it