@subsocial/resource-discussions
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

Subsocial helper for resource-discussions pallet by DappForce

SocialResource is meant to make work with resource-discussions pallet easier. Main goals of this tool:

  • convert resource parameters from object tree view to resourceId string;
  • keep resourceId structure stable and fixed;
  • validate resource parameters object;

Usage example:

import { SocialResource, ResourceParameters } from '@subsocial/resource-discussions'

const resourceParams: ResourceParameters = {
  schema: 'chain',
  chainType: 'substrate',
  chainName: 'xsocial',
  resourceType: 'block',
  resourceValue: {
    blockNumber: '3219502'
  }
}

const resourceInstance = new SocialResource(resourceParams)

const resourceId = resourceInstance.toResourceId()

Types and parameters

ResourceParameters object has sequentially conditional structure. It means, that parameter schema or specific combination of parameters chema and chainType influences to valid combination of further parameters. This flow is controlled by graph-based config structure and TypeScript types. You can investigate all possible parameters combinations in package types.

Package Sidebar

Install

npm i @subsocial/resource-discussions

Weekly Downloads

77

Version

0.0.4

License

none

Unpacked Size

129 kB

Total Files

7

Last publish

Collaborators

  • dappforce
  • olehmell
  • asiman
  • f3joule