From 4f9211f7416de76f2505c8aa67226bfdbd676409 Mon Sep 17 00:00:00 2001 From: Dominic Tarr Date: Tue, 16 Apr 2019 09:14:20 +1200 Subject: [PATCH 1/2] muxrpcli@3 style help --- help.js | 39 +++++++++++++++++++++++++++++++++++++++ index.js | 5 ++++- legacy.js | 8 ++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 help.js diff --git a/help.js b/help.js new file mode 100644 index 0000000..2849a78 --- /dev/null +++ b/help.js @@ -0,0 +1,39 @@ + +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: { + 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)' + } + } + } + } +} + + diff --git a/index.js b/index.js index 32b1024..4e0c324 100644 --- a/index.js +++ b/index.js @@ -28,7 +28,10 @@ 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') } } } From 1f5dc9cca4e0d3e894cbb5e1bceb431e8e1ca984 Mon Sep 17 00:00:00 2001 From: Dominic Tarr Date: Tue, 16 Apr 2019 09:35:36 +1200 Subject: [PATCH 2/2] add upto and changes to help, remove api.md --- api.md | 35 ----------------------------------- help.js | 17 +++++++++++++++++ index.js | 4 +++- manifest.json | 8 ++++++++ package.json | 2 +- 5 files changed, 29 insertions(+), 37 deletions(-) delete mode 100644 api.md create mode 100644 manifest.json 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 index 2849a78..3fca3bc 100644 --- a/help.js +++ b/help.js @@ -18,6 +18,8 @@ module.exports = { }, block: { + type: 'sync', + description: 'block or unblock replication of a feed', args: { from: { type: 'FeedId', @@ -32,6 +34,21 @@ module.exports = { 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 4e0c324..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 @@ -36,3 +37,4 @@ module.exports = { } } + 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" } +