Agent client for Javascript
Installation
Browser
<!-- Polyfill for browser compatibility --><!-- Actual Stratumn SDK -->
If you want a specific version, include https://libs.stratumn.com/stratumn-agent-client-{version}.min.js
instead (for instance https://libs.stratumn.com/stratumn-agent-client-1.0.2.min.js
).
Node.js
$ npm install stratumn-agent-client
var AgentClient = ;
Quickstart
AgentClient ;
Reference
AgentClient#getAgent(url)
Returns a promise that resolves with an agent client targetting the agent server available at url
.
AgentClient ;
AgentClient#getAgent(obj)
Returns a promise that resolves with an agent client targetting the agent object created previously.
const agentObj = ;AgentClient ;
AgentClient#fromSegment(rawSegment)
Returns a promise that resolves with the agent and segment from a given raw object.
AgentClient ;
Process#createMap(...args)
Returns a promise that resolves with a the first segment of a map.
AgentClient ;
Process#getSegment(linkHash)
Returns a promise that resolves with an existing segment.
AgentClient ;
Process#findSegments(opts)
Returns a promise that resolves with existing segments.
Available options are:
offset
: offset of first returned segmentslimit
: limit number of returned segments, if -1 load all segmentsbatchSize
: size of each batch when loading all segments (default 20)mapIds
: return segments with specified map IDprevLinkHash
: return segments with specified previous link hashtags
: return segments that contains all the tags (array)
AgentClient ;
Process#getMapIds(opts)
Returns a promise that resolves with existing map IDs.
Available options are:
offset
: offset of first returned map IDlimit
: limit number of returned map ID
AgentClient ;
Segment#getPrev()
Returns a promise that resolves with the previous segment.
AgentClient ;
Segment#:actionName(...args)
Executes an action and returns a promise that resolves with a new segment.
AgentClient ;
Development
Install dependencies:
$ npm install
Build:
$ npm run build
Test:
$ npm test
Test coverage:
$ npm run test:cov
$ open coverage/lcov-report/index.html
Lint:
$ npm run lint
Lint and test:
$ npm run check
Bump version:
$ npm version major|minor|patch
Publish:
$ npm publish