diff --git a/api.md b/api.md deleted file mode 100644 index 78158a6..0000000 --- a/api.md +++ /dev/null @@ -1,35 +0,0 @@ -# ssb-server replicate plugin - -Sync feeds between peers. - - -## changes: source - -Listen to replicate events. - -```bash -changes -``` - -```js -changes() -``` - -Emits events of the following form: - -``` -{ type: 'progress', peerid:, total:, progress:, feeds:, sync: } -``` - -## upto: source - -returns {} of feeds to replicate, with sequences - -## request: sync - -request a given feed, either as request(id) to replicate that feed, -or request(id, false) to disable replication. - -## block: sync - -call when `from` blocks `to`: `block(from, to, isBlocking)`. diff --git a/help.js b/help.js new file mode 100644 index 0000000..3fca3bc --- /dev/null +++ b/help.js @@ -0,0 +1,56 @@ + +module.exports = { + description: 'legacy replication & stub api for replication', + commands: { + request: { + type: 'sync', + description: 'request a specific feed to be replicated or not', + args: { + id: { + type: 'FeedId', + description: 'FeedId to enable or disable replication' + }, + replicate: { + type: 'boolean', + description: 'wether to replicate this feed, defaults to true' + } + } + + }, + block: { + type: 'sync', + description: 'block or unblock replication of a feed', + args: { + from: { + type: 'FeedId', + description: 'feed id which created the block' + }, + to: { + type: 'FeedId', + description: 'feed id which was blocked' + }, + blocking: { + type: 'boolean', + description: 'wether this is a block or unblock, defaults to unblock (false)' + } + } + }, + upto: { + type: 'source', + description: 'stream {id, sequence} tuples of the sequence you are up to for every feed', + args: { + live: { + type: 'boolean', + description: 'include real time changes to replication state, such as new feeds followed' + } + } + }, + changes: { + type: 'source', + description: 'stream of replication change events, recommend polling sbot.progress instead', + args: {} + } + } +} + + diff --git a/index.js b/index.js index 32b1024..49b62dd 100644 --- a/index.js +++ b/index.js @@ -9,7 +9,8 @@ var pull = require('pull-stream') module.exports = { name: 'replicate', version: '2.0.0', - manifest: mdm.manifest(fs.readFileSync(path.join(__dirname, 'api.md'), 'utf8')), + manifest: require('./manifest.json'), +//mdm.manifest(fs.readFileSync(path.join(__dirname, 'api.md'), 'utf8')), //replicate: replicate, init: function (ssbServer, config) { var notify = Notify(), upto @@ -28,8 +29,12 @@ module.exports = { return { request: function () {}, block: function (from, to, blocking) {}, - changes: function () { return function (abort, cb) { cb(true) } } + changes: function () { return function (abort, cb) { cb(true) } }, + help: function () { + return require('./help') + } } } } + diff --git a/legacy.js b/legacy.js index 43b7fd6..e3c7ef8 100644 --- a/legacy.js +++ b/legacy.js @@ -389,6 +389,11 @@ module.exports = function (ssbServer, notify, config) { upto: upto, changes: notify.listen, block: function (from, to, blocking) { + if(isObject(from)) { + to = from.to + blocking = from.blocking + from = from.from + } if(blocking) { blocks[from] = blocks[from] || {} blocks[from][to] = blocking @@ -396,6 +401,9 @@ module.exports = function (ssbServer, notify, config) { else if (blocks[from]) { delete blocks[from][to] } + }, + help: function () { + return require('./help') } } } diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..fd04b17 --- /dev/null +++ b/manifest.json @@ -0,0 +1,8 @@ + +{ + "changes": "source", + "upto": "source", + "request": "sync", + "block": "sync" +} + diff --git a/package.json b/package.json index 7c5acb9..14eed6f 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ }, "dependencies": { "deep-equal": "^1.0.1", - "mdmanifest": "^1.0.8", "observ-debounce": "^1.1.1", "obv": "0.0.1", "pull-cat": "^1.1.11", @@ -36,3 +35,4 @@ "author": "Dominic Tarr (http://dominictarr.com)", "license": "MIT" } +