mapexplorer-rails 1.0.0.pre.alpha → 1.0.0.pre.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mapexplorer/rails/version.rb +1 -1
- data/vendor/assets/babel-polyfill/README.md +0 -0
- data/vendor/assets/babel-polyfill/bower.json +22 -0
- data/vendor/assets/babel-polyfill/browser-polyfill.js +5 -0
- data/vendor/assets/d3/LICENSE +27 -0
- data/vendor/assets/d3/README.md +45 -0
- data/vendor/assets/d3/bower.json +7 -0
- data/vendor/assets/d3/d3.js +16383 -0
- data/vendor/assets/d3/d3.min.js +8 -0
- data/vendor/assets/jsrender/MIT-LICENSE.txt +20 -0
- data/vendor/assets/jsrender/bower.json +43 -0
- data/vendor/assets/jsrender/index.js +8 -0
- data/vendor/assets/jsrender/jsrender-node.js +2298 -0
- data/vendor/assets/jsrender/jsrender.js +2350 -0
- data/vendor/assets/jsrender/jsrender.min.js +4 -0
- data/vendor/assets/jsrender/jsrender.min.js.map +1 -0
- data/vendor/assets/jsrender/tmplify/index.js +64 -0
- data/vendor/assets/mapexplorer-core/LICENSE +21 -0
- data/vendor/assets/mapexplorer-core/README.md +235 -0
- data/vendor/assets/mapexplorer-core/assets/stylesheets/map.scss +38 -0
- data/vendor/assets/mapexplorer-core/assets/stylesheets/mapexplorer-core.scss +3 -0
- data/vendor/assets/mapexplorer-core/assets/stylesheets/merkle-path.scss +10 -0
- data/vendor/assets/mapexplorer-core/assets/stylesheets/variables.scss +14 -0
- data/vendor/assets/mapexplorer-core/bower.json +32 -0
- data/vendor/assets/mapexplorer-core/dist/mapexplorer-core.js +3872 -0
- data/vendor/assets/mapexplorer-core/dist/mapexplorer-core.js.map +1 -0
- data/vendor/assets/mapexplorer-core/dist/mapexplorer-core.min.js +35 -0
- data/vendor/assets/mapexplorer-core/karma.conf.js +117 -0
- data/vendor/assets/mapexplorer-core/package.json +85 -0
- data/vendor/assets/mapexplorer-core/rollup.bower.config.js +41 -0
- data/vendor/assets/mapexplorer-core/rollup.es.config.js +16 -0
- data/vendor/assets/mapexplorer-core/rollup.umd.config.js +25 -0
- data/vendor/assets/stratumn-sdk/LICENSE +21 -0
- data/vendor/assets/stratumn-sdk/README.md +267 -0
- data/vendor/assets/stratumn-sdk/bower.json +27 -0
- data/vendor/assets/stratumn-sdk/dist/stratumn-sdk.js +813 -0
- data/vendor/assets/stratumn-sdk/dist/stratumn-sdk.js.map +1 -0
- data/vendor/assets/stratumn-sdk/dist/stratumn-sdk.min.js +2 -0
- data/vendor/assets/stratumn-sdk/dist/stratumn-sdk.min.js.map +1 -0
- data/vendor/assets/stratumn-sdk/examples/browser/index.html +34 -0
- data/vendor/assets/stratumn-sdk/package.json +67 -0
- data/vendor/assets/stratumn-sdk/rollup.base.config.js +13 -0
- data/vendor/assets/stratumn-sdk/rollup.bower.config.js +18 -0
- data/vendor/assets/stratumn-sdk/rollup.bower.min.config.js +7 -0
- data/vendor/assets/stratumn-sdk/rollup.es.config.js +9 -0
- data/vendor/assets/stratumn-sdk/rollup.umd.config.js +10 -0
- metadata +46 -1
@@ -0,0 +1,117 @@
|
|
1
|
+
var path = require('path');
|
2
|
+
var babel = require('rollup-plugin-babel');
|
3
|
+
var babelrc = require('babelrc-rollup').default;
|
4
|
+
var json = require('rollup-plugin-json');
|
5
|
+
var commonjs = require('rollup-plugin-commonjs');
|
6
|
+
var nodeResolve = require('rollup-plugin-node-resolve');
|
7
|
+
var builtins = require('rollup-plugin-node-builtins');
|
8
|
+
|
9
|
+
module.exports = function(config) {
|
10
|
+
config.set({
|
11
|
+
// base path, that will be used to resolve files and exclude
|
12
|
+
basePath: '',
|
13
|
+
|
14
|
+
// frameworks to use
|
15
|
+
frameworks: ['mocha', 'should', 'sinon'],
|
16
|
+
|
17
|
+
|
18
|
+
// list of files / patterns to load in the browser
|
19
|
+
files: [
|
20
|
+
'bower_components/babel-polyfill/browser-polyfill.js',
|
21
|
+
'bower_components/d3/d3.js',
|
22
|
+
'dist/mapexplorer-core.js',
|
23
|
+
'test/integration/*.test.js'
|
24
|
+
],
|
25
|
+
|
26
|
+
preprocessors: {
|
27
|
+
'test/integration/*.test.js': ['rollup']
|
28
|
+
},
|
29
|
+
|
30
|
+
rollupPreprocessor: {
|
31
|
+
plugins: [
|
32
|
+
json(),
|
33
|
+
babel(Object.assign({
|
34
|
+
exclude: 'node_modules/**'
|
35
|
+
}, babelrc())),
|
36
|
+
builtins(),
|
37
|
+
nodeResolve({
|
38
|
+
jsnext: true,
|
39
|
+
browser: true,
|
40
|
+
preferBuiltins: true,
|
41
|
+
skip: ['d3-selection', 'mapexplorer-core']
|
42
|
+
}),
|
43
|
+
commonjs({
|
44
|
+
// non-CommonJS modules will be ignored, but you can also
|
45
|
+
// specifically include/exclude files
|
46
|
+
// include: 'node_modules/**', // Default: undefined
|
47
|
+
// exclude: [],
|
48
|
+
exclude: ['node_modules/rollup-plugin-node-globals/**']
|
49
|
+
})
|
50
|
+
],
|
51
|
+
globals: {
|
52
|
+
'd3-selection': 'd3',
|
53
|
+
'mapexplorer-core': 'mapexplorerCore'
|
54
|
+
},
|
55
|
+
// will help to prevent conflicts between different tests entries
|
56
|
+
format: 'iife',
|
57
|
+
sourceMap: 'inline'
|
58
|
+
},
|
59
|
+
|
60
|
+
// list of files to exclude
|
61
|
+
exclude: [],
|
62
|
+
|
63
|
+
|
64
|
+
// test results reporter to use
|
65
|
+
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
|
66
|
+
reporters: ['progress'],
|
67
|
+
|
68
|
+
|
69
|
+
// web server port
|
70
|
+
port: 9876,
|
71
|
+
|
72
|
+
|
73
|
+
// enable / disable colors in the output (reporters and logs)
|
74
|
+
colors: true,
|
75
|
+
|
76
|
+
|
77
|
+
// level of logging
|
78
|
+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
79
|
+
logLevel: config.LOG_INFO,
|
80
|
+
|
81
|
+
|
82
|
+
// enable / disable watching file and executing tests whenever any file changes
|
83
|
+
autoWatch: true,
|
84
|
+
|
85
|
+
|
86
|
+
// Start these browsers, currently available:
|
87
|
+
// - Chrome
|
88
|
+
// - ChromeCanary
|
89
|
+
// - Firefox
|
90
|
+
// - Opera (has to be installed with `npm install karma-opera-launcher`)
|
91
|
+
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
|
92
|
+
// - PhantomJS
|
93
|
+
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
|
94
|
+
browsers: ['PhantomJS', 'Chrome'],
|
95
|
+
|
96
|
+
|
97
|
+
// If browser does not capture in given timeout [ms], kill it
|
98
|
+
captureTimeout: 60000,
|
99
|
+
|
100
|
+
|
101
|
+
// Continuous Integration mode
|
102
|
+
// if true, it capture browsers, run tests and exit
|
103
|
+
singleRun: false
|
104
|
+
});
|
105
|
+
|
106
|
+
if (process.env.TRAVIS){
|
107
|
+
config.set({
|
108
|
+
browsers: ['TravisCI_Chrome', 'PhantomJS'],
|
109
|
+
customLaunchers: {
|
110
|
+
TravisCI_Chrome: {
|
111
|
+
base: 'Chrome',
|
112
|
+
flags: ['--no-sandbox']
|
113
|
+
}
|
114
|
+
}
|
115
|
+
});
|
116
|
+
}
|
117
|
+
};
|
@@ -0,0 +1,85 @@
|
|
1
|
+
{
|
2
|
+
"name": "mapexplorer-core",
|
3
|
+
"version": "1.0.0-alpha",
|
4
|
+
"description": "Core library for building Map Explorer components",
|
5
|
+
"main": "lib/mapexplorer-core.js",
|
6
|
+
"module": "lib/mapexplorer-core.mjs",
|
7
|
+
"jsnext:main": "lib/mapexplorer-core.mjs",
|
8
|
+
"scripts": {
|
9
|
+
"test": "npm run test:unit && npm run test:integration",
|
10
|
+
"test:unit": "mocha --compilers js:babel-register --require should test/unit/*",
|
11
|
+
"test:integration": "karma start karma.conf.js",
|
12
|
+
"test:integration:ci": "npm run test:integration -- --single-run",
|
13
|
+
"test:ci": "npm run test:unit && npm run test:integration:ci",
|
14
|
+
"prebuild": "eslint src test",
|
15
|
+
"build:npm": "rollup -c rollup.es.config.js && rollup -c rollup.umd.config.js",
|
16
|
+
"build:bower": "rollup -c rollup.bower.config.js",
|
17
|
+
"build": "npm run build:npm && npm run build:bower",
|
18
|
+
"watch": "rollup -c -w",
|
19
|
+
"prepublish": "npm run build:npm"
|
20
|
+
},
|
21
|
+
"repository": {
|
22
|
+
"type": "git",
|
23
|
+
"url": "https://github.com/stratumn/mapexplorer-core.git"
|
24
|
+
},
|
25
|
+
"keywords": [
|
26
|
+
"stratumn",
|
27
|
+
"blockchain",
|
28
|
+
"mapexplorer",
|
29
|
+
"chainscript"
|
30
|
+
],
|
31
|
+
"author": "Stratumn Team",
|
32
|
+
"license": "MIT",
|
33
|
+
"bugs": {
|
34
|
+
"url": "https://github.com/stratumn/mapexplorer-core/issues"
|
35
|
+
},
|
36
|
+
"homepage": "https://github.com/stratumn/mapexplorer-core",
|
37
|
+
"devDependencies": {
|
38
|
+
"babel-cli": "^6.5.1",
|
39
|
+
"babel-eslint": "^6.0.0",
|
40
|
+
"babel-plugin-external-helpers": "^6.8.0",
|
41
|
+
"babel-plugin-transform-object-rest-spread": "^6.8.0",
|
42
|
+
"babel-preset-es2015": "^6.5.0",
|
43
|
+
"babel-register": "^6.11.6",
|
44
|
+
"babelrc-rollup": "^3.0.0",
|
45
|
+
"crypto-browserify": "^3.11.0",
|
46
|
+
"eslint": "^2.3.0",
|
47
|
+
"eslint-config-airbnb": "^6.0.2",
|
48
|
+
"eslint-plugin-react": "^4.1.0",
|
49
|
+
"karma": "^1.1.1",
|
50
|
+
"karma-chrome-launcher": "^2.0.0",
|
51
|
+
"karma-mocha": "^1.1.1",
|
52
|
+
"karma-phantomjs-launcher": "^1.0.1",
|
53
|
+
"karma-rollup-plugin": "^0.2.2",
|
54
|
+
"karma-should": "^1.0.0",
|
55
|
+
"karma-sinon": "^1.0.5",
|
56
|
+
"karma-sourcemap-loader": "^0.3.7",
|
57
|
+
"mocha": "^2.4.5",
|
58
|
+
"rimraf": "^2.5.2",
|
59
|
+
"rollup": "^0.34.7",
|
60
|
+
"rollup-plugin-babel": "^2.6.1",
|
61
|
+
"rollup-plugin-coffee-script": "^1.1.0",
|
62
|
+
"rollup-plugin-commonjs": "^3.3.1",
|
63
|
+
"rollup-plugin-json": "^2.0.1",
|
64
|
+
"rollup-plugin-node-builtins": "^1.0.7",
|
65
|
+
"rollup-plugin-node-globals": "^1.0.6",
|
66
|
+
"rollup-plugin-node-resolve": "^2.0.0",
|
67
|
+
"rollup-watch": "^2.5.0",
|
68
|
+
"should": "^8.2.2",
|
69
|
+
"sinon": "^1.17.5",
|
70
|
+
"zock": "^0.2.6"
|
71
|
+
},
|
72
|
+
"dependencies": {
|
73
|
+
"canonical-json": "0.0.4",
|
74
|
+
"d3-array": "^1.0.0",
|
75
|
+
"d3-ease": "^1.0.0",
|
76
|
+
"d3-hierarchy": "^1.0.0",
|
77
|
+
"d3-selection": "^1.0.0",
|
78
|
+
"d3-transition": "^1.0.1",
|
79
|
+
"d3-zoom": "^1.0.2",
|
80
|
+
"deepmerge": "^0.2.10",
|
81
|
+
"httpplease": "^0.16.4",
|
82
|
+
"js-sha256": "^0.3.0",
|
83
|
+
"stratumn-sdk": "^1.2.2"
|
84
|
+
}
|
85
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
var babel = require('rollup-plugin-babel');
|
2
|
+
var babelrc = require('babelrc-rollup').default;
|
3
|
+
var commonjs = require('rollup-plugin-commonjs');
|
4
|
+
var nodeResolve = require('rollup-plugin-node-resolve');
|
5
|
+
var json = require('rollup-plugin-json');
|
6
|
+
var builtins = require('rollup-plugin-node-builtins');
|
7
|
+
var globals = require('rollup-plugin-node-globals');
|
8
|
+
|
9
|
+
module.exports = {
|
10
|
+
plugins: [
|
11
|
+
json(),
|
12
|
+
babel(Object.assign({
|
13
|
+
exclude: 'node_modules/**'
|
14
|
+
}, babelrc())),
|
15
|
+
builtins(),
|
16
|
+
nodeResolve({
|
17
|
+
jsnext: true,
|
18
|
+
browser: true,
|
19
|
+
preferBuiltins: true,
|
20
|
+
skip: ['d3-hierarchy', 'd3-transition', 'd3-ease', 'd3-selection', 'd3-zoom', 'd3-array']
|
21
|
+
}),
|
22
|
+
commonjs({
|
23
|
+
exclude: ['node_modules/rollup-plugin-node-globals/**',
|
24
|
+
'node_modules/process-es6/**', 'node_modules/buffer-es6/**']
|
25
|
+
}),
|
26
|
+
globals()
|
27
|
+
],
|
28
|
+
format: 'umd',
|
29
|
+
sourceMap: true,
|
30
|
+
globals: {
|
31
|
+
'd3-hierarchy': 'd3',
|
32
|
+
'd3-transition': 'd3',
|
33
|
+
'd3-ease': 'd3',
|
34
|
+
'd3-selection': 'd3',
|
35
|
+
'd3-zoom': 'd3',
|
36
|
+
'd3-array': 'd3'
|
37
|
+
},
|
38
|
+
entry: 'src/index.js',
|
39
|
+
dest: 'dist/mapexplorer-core.js',
|
40
|
+
moduleName: 'mapexplorerCore'
|
41
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
var babel = require('rollup-plugin-babel');
|
2
|
+
var babelrc = require('babelrc-rollup').default;
|
3
|
+
|
4
|
+
var pkg = require('./package.json');
|
5
|
+
var external = Object.keys(pkg.dependencies);
|
6
|
+
|
7
|
+
module.exports = {
|
8
|
+
entry: 'src/index.js',
|
9
|
+
plugins: [
|
10
|
+
babel(babelrc())
|
11
|
+
],
|
12
|
+
external: external,
|
13
|
+
dest: pkg['jsnext:main'],
|
14
|
+
format: 'es',
|
15
|
+
sourceMap: true
|
16
|
+
};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
var babel = require('rollup-plugin-babel');
|
2
|
+
var babelrc = require('babelrc-rollup').default;
|
3
|
+
|
4
|
+
var pkg = require('./package.json');
|
5
|
+
var external = Object.keys(pkg.dependencies);
|
6
|
+
|
7
|
+
module.exports = {
|
8
|
+
entry: 'src/index.js',
|
9
|
+
plugins: [
|
10
|
+
babel(babelrc())
|
11
|
+
],
|
12
|
+
external: external,
|
13
|
+
globals: {
|
14
|
+
'd3-hierarchy': 'd3',
|
15
|
+
'd3-transition': 'd3',
|
16
|
+
'd3-ease': 'd3',
|
17
|
+
'd3-selection': 'd3',
|
18
|
+
'd3-zoom': 'd3',
|
19
|
+
'd3-array': 'd3'
|
20
|
+
},
|
21
|
+
dest: pkg['main'],
|
22
|
+
format: 'umd',
|
23
|
+
moduleName: 'mapexplorerCore',
|
24
|
+
sourceMap: true
|
25
|
+
};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Stratumn
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,267 @@
|
|
1
|
+
# Stratumn SDK for Javascript [ALPHA - incompatible with production]
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/stratumn/stratumn-sdk-js.svg?branch=alpha)](https://travis-ci.org/stratumn/stratumn-sdk-js)
|
4
|
+
[![codecov](https://codecov.io/gh/stratumn/stratumn-sdk-js/branch/alpha/graph/badge.svg)](https://codecov.io/gh/stratumn/stratumn-sdk-js/branch/alpha)
|
5
|
+
[![Build Status](https://david-dm.org/stratumn/stratumn-sdk-js.svg?branch=alpha)](https://david-dm.org/stratumn/stratumn-sdk-js)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
### Browser
|
10
|
+
|
11
|
+
```html
|
12
|
+
<!-- Polyfill for browser compatibility -->
|
13
|
+
<script src="https://libs.stratumn.com/babel-polyfill.min.js"></script>
|
14
|
+
<!-- Actual Stratumn SDK -->
|
15
|
+
<script src="https://libs.stratumn.com/stratumn-sdk.min.js"></script>
|
16
|
+
```
|
17
|
+
|
18
|
+
If you want a specific version, include `https://libs.stratumn.com/stratumn-sdk-{version}.min.js` instead (for instance `https://libs.stratumn.com/stratumn-sdk-1.0.2.min.js`).
|
19
|
+
|
20
|
+
### Bower
|
21
|
+
|
22
|
+
```
|
23
|
+
$ bower install stratumn-sdk
|
24
|
+
```
|
25
|
+
|
26
|
+
### Node.js
|
27
|
+
|
28
|
+
```
|
29
|
+
$ npm install stratumn-sdk@alpha
|
30
|
+
```
|
31
|
+
|
32
|
+
```javascript
|
33
|
+
var StratumnSDK = require('stratumn-sdk');
|
34
|
+
```
|
35
|
+
|
36
|
+
## Quickstart
|
37
|
+
|
38
|
+
```javascript
|
39
|
+
StratumnSDK.getAgent('http://localhost:3000')
|
40
|
+
.then(function(agent) {
|
41
|
+
console.log(agent);
|
42
|
+
// Create a new map, you can pass arguments to init
|
43
|
+
return agent.createMap('My conversation');
|
44
|
+
})
|
45
|
+
.then(function(segment) {
|
46
|
+
// You can call an action like a regular function
|
47
|
+
return segment.addMessage('Hello, World');
|
48
|
+
})
|
49
|
+
.then(function(segment) {
|
50
|
+
console.log(segment.link);
|
51
|
+
console.log(segment.meta);
|
52
|
+
})
|
53
|
+
.catch(function(err) {
|
54
|
+
// Handle errors
|
55
|
+
});
|
56
|
+
```
|
57
|
+
|
58
|
+
## Reference
|
59
|
+
|
60
|
+
### StratumnSDK#getAgent(url)
|
61
|
+
|
62
|
+
Returns a promise that resolves with an agent client.
|
63
|
+
|
64
|
+
```javascript
|
65
|
+
StratumnSDK
|
66
|
+
.getAgent('http://localhost:3000')
|
67
|
+
.then(function(agent) {
|
68
|
+
console.log(agent);
|
69
|
+
})
|
70
|
+
.catch(function(err) {
|
71
|
+
// Handle errors
|
72
|
+
});
|
73
|
+
```
|
74
|
+
|
75
|
+
### StratumnSDK#fromSegment(rawSegment)
|
76
|
+
|
77
|
+
Returns a promise that resolves with the agent and segment from a given raw object.
|
78
|
+
|
79
|
+
```javascript
|
80
|
+
StratumnSDK
|
81
|
+
.fromSegment(someRawSegment)
|
82
|
+
.then(function(res) {
|
83
|
+
console.log(res.agent);
|
84
|
+
console.log(res.segment);
|
85
|
+
})
|
86
|
+
.catch(function(err) {
|
87
|
+
// Handle errors
|
88
|
+
});
|
89
|
+
```
|
90
|
+
|
91
|
+
### Agent#createMap(...args)
|
92
|
+
|
93
|
+
Returns a promise that resolves with a the first segment of a map.
|
94
|
+
|
95
|
+
```javascript
|
96
|
+
StratumnSDK
|
97
|
+
.getAgent('http://localhost:3000')
|
98
|
+
.then(function(agent) {
|
99
|
+
return agent.createMap('A new map');
|
100
|
+
})
|
101
|
+
.then(function(segment) {
|
102
|
+
console.log(segment);
|
103
|
+
})
|
104
|
+
.catch(function(err) {
|
105
|
+
// Handle errors
|
106
|
+
});
|
107
|
+
```
|
108
|
+
|
109
|
+
### Agent#getSegment(linkHash)
|
110
|
+
|
111
|
+
Returns a promise that resolves with an existing segment.
|
112
|
+
|
113
|
+
```javascript
|
114
|
+
StratumnSDK
|
115
|
+
.getAgent('http://localhost:3000')
|
116
|
+
.then(function(agent) {
|
117
|
+
return agent.getSegment('aee5427');
|
118
|
+
})
|
119
|
+
.then(function(segment) {
|
120
|
+
console.log(segment);
|
121
|
+
})
|
122
|
+
.catch(function(err) {
|
123
|
+
// Handle errors
|
124
|
+
});
|
125
|
+
```
|
126
|
+
|
127
|
+
### Agent#findSegments(opts)
|
128
|
+
|
129
|
+
Returns a promise that resolves with existing segments.
|
130
|
+
|
131
|
+
Available options are:
|
132
|
+
|
133
|
+
- `offset`: offset of first returned segments
|
134
|
+
- `limit`: limit number of returned segments
|
135
|
+
- `mapId`: return segments with specified map ID
|
136
|
+
- `prevLinkHash`: return segments with specified previous link hash
|
137
|
+
- `tags`: return segments that contains all the tags (array)
|
138
|
+
|
139
|
+
```javascript
|
140
|
+
StratumnSDK
|
141
|
+
.getAgent('http://localhost:3000')
|
142
|
+
.then(function(agent) {
|
143
|
+
return agent.findSegments({ tags: ['tag1', 'tag2'], offset: 20, limit: 10 });
|
144
|
+
})
|
145
|
+
.then(function(segments) {
|
146
|
+
console.log(segments);
|
147
|
+
})
|
148
|
+
.catch(function(err) {
|
149
|
+
// Handle errors
|
150
|
+
});
|
151
|
+
```
|
152
|
+
|
153
|
+
### Agent#getMapIds(opts)
|
154
|
+
|
155
|
+
Returns a promise that resolves with existing map IDs.
|
156
|
+
|
157
|
+
Available options are:
|
158
|
+
|
159
|
+
- `offset`: offset of first returned map ID
|
160
|
+
- `limit`: limit number of returned map ID
|
161
|
+
|
162
|
+
```javascript
|
163
|
+
StratumnSDK
|
164
|
+
.getAgent('http://localhost:3000')
|
165
|
+
.then(function(agent) {
|
166
|
+
return agent.findSegments({ offset: 20, limit: 10 });
|
167
|
+
})
|
168
|
+
.then(function(mapIDs) {
|
169
|
+
console.log(mapIDs);
|
170
|
+
})
|
171
|
+
.catch(function(err) {
|
172
|
+
// Handle errors
|
173
|
+
});
|
174
|
+
```
|
175
|
+
|
176
|
+
### Segment#getPrev()
|
177
|
+
|
178
|
+
Returns a promise that resolves with the previous segment.
|
179
|
+
|
180
|
+
```javascript
|
181
|
+
StratumnSDK
|
182
|
+
.getAgent('http://localhost:3000')
|
183
|
+
.then(function(agent) {
|
184
|
+
return agent.getSegment('aee5427');
|
185
|
+
})
|
186
|
+
.then(function(segment) {
|
187
|
+
return segment.getPrev();
|
188
|
+
})
|
189
|
+
.then(function(segment) {
|
190
|
+
console.log(segment);
|
191
|
+
})
|
192
|
+
.catch(function(err) {
|
193
|
+
// Handle errors
|
194
|
+
});
|
195
|
+
```
|
196
|
+
|
197
|
+
### Segment#:actionName(...args)
|
198
|
+
|
199
|
+
Executes an action and returns a promise that resolves with a new segment.
|
200
|
+
|
201
|
+
```javascript
|
202
|
+
StratumnSDK
|
203
|
+
.getAgent('http://localhost:3000')
|
204
|
+
.then(function(agent) {
|
205
|
+
return agent.getSegment('aee5427');
|
206
|
+
})
|
207
|
+
.then(function(segment) {
|
208
|
+
return segment.addMessage('Hello, World!');
|
209
|
+
})
|
210
|
+
.then(function(segment) {
|
211
|
+
console.log(segment);
|
212
|
+
})
|
213
|
+
.catch(function(err) {
|
214
|
+
// Handle errors
|
215
|
+
});
|
216
|
+
```
|
217
|
+
|
218
|
+
## Development
|
219
|
+
|
220
|
+
Install dependencies:
|
221
|
+
|
222
|
+
```
|
223
|
+
$ npm install
|
224
|
+
```
|
225
|
+
|
226
|
+
Build:
|
227
|
+
|
228
|
+
```
|
229
|
+
$ npm run build:all
|
230
|
+
```
|
231
|
+
|
232
|
+
Test:
|
233
|
+
|
234
|
+
```
|
235
|
+
$ npm test
|
236
|
+
```
|
237
|
+
|
238
|
+
Test coverage:
|
239
|
+
|
240
|
+
```
|
241
|
+
$ npm run test:cov
|
242
|
+
$ open coverage/lcov-report/index.html
|
243
|
+
```
|
244
|
+
|
245
|
+
Lint:
|
246
|
+
|
247
|
+
```
|
248
|
+
$ npm run lint
|
249
|
+
```
|
250
|
+
|
251
|
+
Lint and test:
|
252
|
+
|
253
|
+
```
|
254
|
+
$ npm run check
|
255
|
+
```
|
256
|
+
|
257
|
+
Bump version:
|
258
|
+
|
259
|
+
```
|
260
|
+
$ npm version major|minor|patch
|
261
|
+
```
|
262
|
+
|
263
|
+
Publish:
|
264
|
+
|
265
|
+
```
|
266
|
+
$ npm publish
|
267
|
+
```
|
@@ -0,0 +1,27 @@
|
|
1
|
+
{
|
2
|
+
"name": "stratumn-sdk",
|
3
|
+
"description": "Stratumn SDK for Javascript",
|
4
|
+
"main": "dist/stratumn-sdk.js",
|
5
|
+
"authors": [
|
6
|
+
"Stratumn Team"
|
7
|
+
],
|
8
|
+
"license": "MIT",
|
9
|
+
"keywords": [
|
10
|
+
"stratumn",
|
11
|
+
"lib",
|
12
|
+
"blockchain",
|
13
|
+
"client"
|
14
|
+
],
|
15
|
+
"homepage": "https://github.com/stratumn/stratumn-sdk-js",
|
16
|
+
"ignore": [
|
17
|
+
"**/.*",
|
18
|
+
"node_modules",
|
19
|
+
"bower_components",
|
20
|
+
"test",
|
21
|
+
"tests",
|
22
|
+
"src"
|
23
|
+
],
|
24
|
+
"dependencies": {
|
25
|
+
"babel-polyfill": "babel/babel/tree/master/packages/babel-polyfill#^0.0.1"
|
26
|
+
}
|
27
|
+
}
|