npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@us3r-network/data-model

v0.7.2-alpha.1

Published

## Base model

Downloads

14

Readme

@us3r-network/data-model

Base model

Basic model for communicating with Ceramic. This model defines the authComposeClient method for ComposeClient authorization.

Profile Model

enum ChainType {
  EVM
  SOLANA
}

type Wallet {
  chain: ChainType!
  address: String! @string(minLength: 20, maxLength: 60)
  primary: Boolean!
}

type Profile @createModel(
    accountRelation: SINGLE,
    description: "profile for us3r-network"
) {
  version: CommitID! @documentVersion
  name: String! @string(minLength: 3, maxLength: 100)
  bio: String @string(minLength: 3, maxLength: 200)
  avatar: String @string(maxLength: 1000)
  tags: [String!] @string(maxLength: 60) @list(maxLength:20)
  wallets: [Wallet!] @list(maxLength:20)
}

ModelCollection Model

type ModelCollection @createModel(accountRelation: LIST, description: "model collection of someone in us3r.network") {
  creator: DID! @documentAccount
  version: CommitID! @documentVersion
  modelID: StreamID!
  notes: String @string(maxLength: 1000)
  revoke: Boolean
  createAt: DateTime
  modifiedAt: DateTime
}

Dapp Model

type SocialLink {
  platform: String! @string(minLength: 1, maxLength: 60)
  url: URI!
}

type Dapp @createModel(
  accountRelation: LIST,
  description: "s3 dapp for us3r-network"
) {
  version: CommitID! @documentVersion
  name: String! @string(minLength: 3, maxLength: 100)
  description: String @string(minLength: 3, maxLength: 200)
  icon: URI
  url: URI
  tags: [String!] @string(maxLength: 60) @list(maxLength:20)
  socialLink: [SocialLink!] @list(maxLength:20)
  models: [StreamID!] @list(maxLength:100)
}

Link Model

type Link @createModel(accountRelation: LIST, description: "Links in us3r-network") {
  creator: DID! @documentAccount
  version: CommitID! @documentVersion
  type: String! @string(maxLength: 100)
  url: URI!
  title: String! @string(maxLength: 200)
  data: String @string(maxLength: 100000)
  createAt: DateTime
  modifiedAt: DateTime
}

Link Ops Model

type Link @loadModel(id: "${linkModelId}") {
  id: ID!
}

type Comment @createModel(accountRelation: LIST, description: "Comment on a link of us3r.network") {
  creator: DID! @documentAccount
  version: CommitID! @documentVersion
  linkID: StreamID! @documentReference(model: "Link")
  link: Link @relationDocument(property: "linkID")
  text: String! @string(maxLength: 2000)
  revoke: Boolean
  createAt: DateTime
  modifiedAt: DateTime
}

enum VoteType {
  UP_VOTE
  DOWN_VOTE
}

type Vote @createModel(accountRelation: LIST, description: "Vote on a link of us3r.network") {
  creator: DID! @documentAccount
  version: CommitID! @documentVersion
  linkID: StreamID! @documentReference(model: "Link")
  link: Link @relationDocument(property: "linkID")
  type: VoteType!
  revoke: Boolean
  createAt: DateTime
  modifiedAt: DateTime
}

type Favor @createModel(accountRelation: LIST, description: "Favor on a link of us3r.network") {
  creator: DID! @documentAccount
  version: CommitID! @documentVersion
  linkID: StreamID! @documentReference(model: "Link")
  link: Link @relationDocument(property: "linkID")
  revoke: Boolean
  createAt: DateTime
  modifiedAt: DateTime
}

type Score @createModel(accountRelation: LIST, description: "Score on a link of us3r.network") {
  creator: DID! @documentAccount
  version: CommitID! @documentVersion
  linkID: StreamID! @documentReference(model: "Link")
  link: Link @relationDocument(property: "linkID")
  text: String! @string(maxLength: 2000)
  value: Int!
  revoke: Boolean
  createAt: DateTime
  modifiedAt: DateTime
}

Link Relation Model

type Favor @loadModel(id: "${favorModelId}") {
  id: ID!
}

type Score @loadModel(id: "${scoreModelId}") {
  id: ID!
}

type Comment @loadModel(id: "${commentModelId}") {
  id: ID!
}

type Vote @loadModel(id: "${voteModelId}") {
  id: ID!
}
type Link @loadModel(id: "${linkModelId}" ) {
  votesCount: Int! @relationCountFrom(model: "Vote", property: "linkID")
  votes: [Vote]! @relationFrom(model: "Vote", property: "linkID")
  commentsCount: Int! @relationCountFrom(model: "Comment", property: "linkID")
  comments: [Comment]! @relationFrom(model: "Comment", property: "linkID")
  favorsCount: Int! @relationCountFrom(model: "Favor", property: "linkID")
  favors: [Favor]! @relationFrom(model: "Favor", property: "linkID")
  scoresCount: Int! @relationCountFrom(model: "Score", property: "linkID")
  scores: [Score]! @relationFrom(model: "Score", property: "linkID")
}

Install

npm install @us3r-network/data-model

Usage

Init Profile instance

...

import {S3ProfileModel} from '@us3r-network/data-model'

const CERAMIC_HOST = process.env.CERAMIC_HOST

const s3Profile = new S3ProfileModel(CERAMIC_HOST)
...

Auth Profile instance with did-session

const didSession = '...'
s3Profile.authComposeClient(didSession)

S3Profile Read & Write

after authorization, the profile can write with method


...
await s3Profile.mutationPersonalProfile(/** {...profile} */)
...

and read the profile with

...
await s3Profile.queryPersonalProfile()
...

or get others profile with a did

...
await s3Profile.queryProfileWithDid(/** did */)
...

Use With Nestjs

 ...
 @Get()
  async getHello(): Promise<string> {
    const { S3LinkModel } = await import('@us3r-network/data-model');
    const s3link = new S3LinkModel('https://ceramic-testnet.s3.xyz');
    console.log(s3link);
    return this.appService.getHello();
  }
  ...

data model UT

  1. yarn install in root directory
  2. yarn test in packages/data-model directory