0.28.0 • Published 7 months ago

@circles-sdk/profiles v0.28.0

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

@circles-sdk/profiles

A TypeScript package for managing user profiles in the Circles ecosystem. This package provides methods to create, retrieve, and search profiles stored on IPFS through the Circles Profile Service.

Installation

npm install @circles-sdk/profiles

Usage

First, initialize the Profiles class with your profile service URL:

import { Profiles } from '@circles/profiles';

const profiles = new Profiles('https://rpc.aboutcircles.com/profiles');

Creating a Profile

const profile = {
  name: 'John Doe',
  description: 'Web3 Developer',
  imageUrl: 'https://example.com/image.jpg',
  previewImageUrl: 'https://example.com/preview.jpg',
  location: 'Berlin, Germany',
  geoLocation: [52.5200, 13.4050]
};

const cid = await profiles.create(profile);
console.log('Profile created with CID:', cid);

Retrieving Profiles

Get a single profile:

const profile = await profiles.get('QmYourCID');
if (profile) {
  console.log('Profile:', profile);
}

Get multiple profiles:

const cids = ['QmCID1', 'QmCID2', 'QmCID3'];
const profilesMap = await profiles.getMany(cids);
console.log('Profiles:', profilesMap);

Searching Profiles

Basic Search

Search by name (partial match):

const nameResults = await profiles.searchByName('John');
console.log('Profiles matching name:', nameResults);

Search by description (partial match):

const descResults = await profiles.searchByDescription('developer');
console.log('Profiles matching description:', descResults);

Search by address (exact match):

const addressResults = await profiles.searchByAddress('0x123...');
console.log('Profile for address:', addressResults);

Search by CID (exact match):

const cidResults = await profiles.searchByCID('QmYourCID');
console.log('Profile for CID:', cidResults);

Search by registeredName (exact match):

const nameResults = await profiles.searchByRegisteredName('Jo');
console.log('Profile for registeredName:', nameResults);

Search by location (partial match):

const locationResults = await profiles.searchByLocation('Berlin');
console.log('Profiles matching location:', locationResults);

Search with multiple criteria:

const results = await profiles.search({
  name: 'John',
  description: 'developer',
  // address, CID, and registeredName are optional
});
console.log('Search results:', results);

Search by multiple addresses in a batch:

const addresses = ['0x123...', '0x456...', '0x789...'];
const results = await profiles.searchByAddresses(addresses);
console.log('Profiles for addresses:', results);

Search with Complete Profile Data

All search methods accept an optional SearchOptions parameter with a fetchComplete flag to retrieve full profile data including images:

// Search by name with complete profile data
const completeProfiles = await profiles.searchByName('John', { fetchComplete: true });
console.log('Complete profiles:', completeProfiles);

// Search with multiple criteria and complete profile data
const completeResults = await profiles.search({
  name: 'John',
  description: 'developer',
}, { fetchComplete: true });
console.log('Complete search results:', completeResults);

Types

Profile

interface Profile {
  name: string;
  description?: string;
  previewImageUrl?: string;
  imageUrl?: string;
  location?: string;
  geoLocation?: [number, number];
  extensions?: Record<string, any>;
}

GroupProfile

interface GroupProfile extends Profile {
  symbol: string;
}

SearchResultProfile

export interface SearchResultProfile extends Pick<Profile, 'name' | 'description'> {
  CID: string;
  lastUpdatedAt: number;
  address: string;
  registeredName: string | null;
  // Optional fields for complete profiles
  imageUrl?: string;
  previewImageUrl?: string;
  location?: string;
  geoLocation?: [number, number];
}

SearchOptions

interface SearchOptions {
  /**
   * Whether to fetch complete profile data including images.
   */
  fetchComplete?: boolean;
}

SearchCriteria

interface SearchCriteria {
  name?: string;
  description?: string;
  address?: string;
  CID?: string;
  registeredName?: string;
  location?: string;
}
0.20.0

9 months ago

0.19.0

10 months ago

0.15.0

1 year ago

0.15.1

1 year ago

0.17.0

10 months ago

0.15.2

11 months ago

0.15.0-preview1

1 year ago

0.27.2

7 months ago

0.27.1

7 months ago

0.27.0

7 months ago

0.25.1

8 months ago

0.25.0

8 months ago

0.21.3

9 months ago

0.23.0

8 months ago

0.21.2

9 months ago

0.21.1

9 months ago

0.27.3

7 months ago

0.21.0

9 months ago

0.14.1

1 year ago

0.16.0

10 months ago

0.18.0

10 months ago

0.16.0-preview1

10 months ago

0.28.0

7 months ago

0.26.1

7 months ago

0.26.0

7 months ago

0.22.4

8 months ago

0.22.3

9 months ago

0.24.0

8 months ago

0.22.2

9 months ago

0.22.1

9 months ago

0.22.0

9 months ago

0.14.0

1 year ago

0.13.2

1 year ago

0.13.3

1 year ago

0.13.4

1 year ago

0.13.0

1 year ago

0.13.1

1 year ago

0.12.0

1 year ago

0.12.1

1 year ago

0.11.2

1 year ago

0.12.2

1 year ago

0.11.1

1 year ago

0.10.0

1 year ago

0.11.0

1 year ago

0.10.1

1 year ago

0.9.0

1 year ago

0.8.1

1 year ago

0.10.2

1 year ago

0.8.0

1 year ago

0.7.1

1 year ago

0.7.0-preview-1

1 year ago

0.5.0-preview-2

1 year ago

0.5.0-preview-1

1 year ago