1.0.3 • Published 4 years ago

solid-user-search v1.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

solid-user-search

Solid User Search Library is a library for accessing Solid Users...

Installation

 npm install solid-user-search

Usage

Then you can import components like this:

import { PersonDetails, fetchPersonDetails } from 'solid-user-search';
import {
  PersonTypes,
  PersonTypeLists,
  fetchPersonTypeLists
} from 'solid-user-search';
import { fetchConnections } from 'solid-user-search';

Description of objects and functionality available

PersonTypes

This is an enumeration it is used to describe the status of the connection.
The values are:

PersonDetails

Person Details describe a solid user in relation to the logged in user. The object includes the following details of the solid user themselves:

In addition it includes the status of the relationship to the logged in user:

PersonTypeLists

PersonTypeLists are Objects that organize the collection of friends by PersonType. This can be used if...

export type PersonTypeLists = {
  [type in PersonType]: {
    [webId: string]: PersonDetails;
  };
};

Functions to search and return Solid Data

fetchPersonDetails

Fetches and returns the PersonDetails of the user with the given webId. This can be used like this:

const getUserDetails = async () => {
  try {
    await fetchPersonDetails(webId).then(() => {
      //do something
    });
  } catch (e) {
    console.log(e);
  }
};

fetchPersonTypeLists

Fetches and returns the PersonTypeLists for the logged in user. It takes an array of PersonTypes for the data you want to retrieve. If no argument is passed in it will return everything. This function is an async generator. It can be used like this:

(async () => {
  let generator = fetchPersonTypeLists();
  for await (let users of generator) {
    //do something
  }
})();

fetchConnections

Fetches and returns an array of PersonDetails for the logged in user. This function is an async generator. It takes an array of PersonTypes for the data you want to retrieve. If no argument is passed in it will return everything. It can be used like this:

(async () => {
  let generator = fetchConnections([PersonType.friend]);
  for await (let friends of generator) {
    //do something
  }
})();

Changelog

See CHANGELOG.

License

MIT © Inrupt