solid-user-search

1.0.3 • Public • Published

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:

Name Description
me Logged in user
requester Another solid user that is requesting the logged in users friendship
requested Solid users whome the logged in person has requested friendship
friend Another solid user in which both parties have accepted a friendship
blocked Solid users the logged in user has unfriended
stranger Other solid users that are connected in some way to the logged in users current connections

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:

Name DataType
webId string
avatarUrl string | null
fullName string | null
follows string[] | null

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

PersonType PersonType | null

PersonTypeLists

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

export type PersonTypeLists = {
  [type in PersonType]: {
    [webIdstring]: 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

Readme

Keywords

Package Sidebar

Install

npm i solid-user-search

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

461 kB

Total Files

60

Last publish

Collaborators

  • michielbdejong