Comparing version 0.1.11 to 0.1.12
@@ -17,2 +17,3 @@ import Database from "./Database"; | ||
handleNewPeer(peer: Peer): Promise<void>; | ||
statusLines(): Promise<string[]>; | ||
getKeyPair(): Promise<KeyPair | null>; | ||
@@ -19,0 +20,0 @@ setKeyPair(kp: KeyPair | null): void; |
@@ -90,2 +90,33 @@ "use strict"; | ||
}; | ||
Channel.prototype.statusLines = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var lines, _a, _b, _i, dbname, database, _c, _d; | ||
return __generator(this, function (_e) { | ||
switch (_e.label) { | ||
case 0: | ||
lines = []; | ||
_a = []; | ||
for (_b in this.databases) | ||
_a.push(_b); | ||
_i = 0; | ||
_e.label = 1; | ||
case 1: | ||
if (!(_i < _a.length)) return [3 /*break*/, 4]; | ||
dbname = _a[_i]; | ||
database = this.databases[dbname]; | ||
_d = (_c = lines).push; | ||
return [4 /*yield*/, database.statusLine()]; | ||
case 2: | ||
_d.apply(_c, [_e.sent()]); | ||
_e.label = 3; | ||
case 3: | ||
_i++; | ||
return [3 /*break*/, 1]; | ||
case 4: | ||
lines.sort(); | ||
return [2 /*return*/, lines]; | ||
} | ||
}); | ||
}); | ||
}; | ||
// Returns undefined if we are not logged in | ||
@@ -92,0 +123,0 @@ Channel.prototype.getKeyPair = function () { |
@@ -27,2 +27,3 @@ import AxiomObject from "./AxiomObject"; | ||
useFilter(filterer: (obj: AxiomObject) => boolean): Promise<void>; | ||
statusLine(): Promise<string>; | ||
allSignedMessages(): Promise<SignedMessage[]>; | ||
@@ -29,0 +30,0 @@ onMessage(callback: DatabaseCallback): Promise<void>; |
@@ -132,2 +132,16 @@ "use strict"; | ||
}; | ||
Database.prototype.statusLine = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var info; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.db.info()]; | ||
case 1: | ||
info = _a.sent(); | ||
return [2 /*return*/, (this.name + " db has " + info.doc_count + " docs. " + | ||
("seq = " + info.update_seq))]; | ||
} | ||
}); | ||
}); | ||
}; | ||
Database.prototype.allSignedMessages = function () { | ||
@@ -151,3 +165,4 @@ return __awaiter(this, void 0, void 0, function () { | ||
// There's something invalid in the database. | ||
console.error("skipping invalid database record"); | ||
console.error("invalid database document:", row.doc); | ||
console.error(e); | ||
} | ||
@@ -154,0 +169,0 @@ } |
@@ -45,4 +45,3 @@ import Channel from "./Channel"; | ||
statusLine(): string; | ||
statusLines(): string[]; | ||
show(): void; | ||
statusLines(): Promise<string[]>; | ||
handleTick(): void; | ||
@@ -49,0 +48,0 @@ peerKeys(): string[]; |
@@ -116,24 +116,45 @@ "use strict"; | ||
Node.prototype.statusLines = function () { | ||
var lines = [ | ||
"public key: " + this.keyPair.getPublicKey(), | ||
this.statusLine() | ||
]; | ||
for (var _i = 0, _a = this.getPeers(); _i < _a.length; _i++) { | ||
var peer = _a[_i]; | ||
lines.push("Peer " + peer.humanID() + ":"); | ||
lines = lines.concat(peer.statusLines()); | ||
} | ||
for (var _b = 0, _c = this.getPendingPeers(); _b < _c.length; _b++) { | ||
var peer = _c[_b]; | ||
lines.push("Pending Peer " + peer.humanID() + ":"); | ||
lines = lines.concat(peer.statusLines()); | ||
} | ||
return lines; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var lines, _a, _b, _i, cname, channel, clines, _c, _d, peer, _e, _f, peer; | ||
return __generator(this, function (_g) { | ||
switch (_g.label) { | ||
case 0: | ||
lines = [ | ||
"public key: " + this.keyPair.getPublicKey(), | ||
this.statusLine() | ||
]; | ||
_a = []; | ||
for (_b in this.channels) | ||
_a.push(_b); | ||
_i = 0; | ||
_g.label = 1; | ||
case 1: | ||
if (!(_i < _a.length)) return [3 /*break*/, 4]; | ||
cname = _a[_i]; | ||
lines.push("Channel " + cname + ":"); | ||
channel = this.channels[cname]; | ||
return [4 /*yield*/, channel.statusLines()]; | ||
case 2: | ||
clines = _g.sent(); | ||
lines = lines.concat(clines); | ||
_g.label = 3; | ||
case 3: | ||
_i++; | ||
return [3 /*break*/, 1]; | ||
case 4: | ||
for (_c = 0, _d = this.getPeers(); _c < _d.length; _c++) { | ||
peer = _d[_c]; | ||
lines.push("Peer " + peer.humanID() + ":"); | ||
lines = lines.concat(peer.statusLines()); | ||
} | ||
for (_e = 0, _f = this.getPendingPeers(); _e < _f.length; _e++) { | ||
peer = _f[_e]; | ||
lines.push("Pending Peer " + peer.humanID() + ":"); | ||
lines = lines.concat(peer.statusLines()); | ||
} | ||
return [2 /*return*/, lines]; | ||
} | ||
}); | ||
}); | ||
}; | ||
Node.prototype.show = function () { | ||
for (var _i = 0, _a = this.statusLines(); _i < _a.length; _i++) { | ||
var line = _a[_i]; | ||
console.log(line); | ||
} | ||
}; | ||
Node.prototype.handleTick = function () { | ||
@@ -140,0 +161,0 @@ var subticks = 0; |
{ | ||
"name": "axiom-api", | ||
"version": "0.1.11", | ||
"version": "0.1.12", | ||
"description": "API for interacting with the Axiom.org platform", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -54,2 +54,12 @@ import Database from "./Database"; | ||
async statusLines(): Promise<string[]> { | ||
let lines = []; | ||
for (let dbname in this.databases) { | ||
let database = this.databases[dbname]; | ||
lines.push(await database.statusLine()); | ||
} | ||
lines.sort(); | ||
return lines; | ||
} | ||
// Returns undefined if we are not logged in | ||
@@ -56,0 +66,0 @@ async getKeyPair(): Promise<KeyPair | null> { |
@@ -94,2 +94,10 @@ import PouchDB from "pouchdb"; | ||
async statusLine(): Promise<string> { | ||
let info = await this.db.info(); | ||
return ( | ||
`${this.name} db has ${info.doc_count} docs. ` + | ||
`seq = ${info.update_seq}` | ||
); | ||
} | ||
async allSignedMessages(): Promise<SignedMessage[]> { | ||
@@ -104,3 +112,4 @@ let answer = []; | ||
// There's something invalid in the database. | ||
console.error("skipping invalid database record"); | ||
console.error("invalid database document:", row.doc); | ||
console.error(e); | ||
} | ||
@@ -107,0 +116,0 @@ } |
@@ -117,3 +117,3 @@ import Channel from "./Channel"; | ||
// Returns one line of printable status | ||
statusLine() { | ||
statusLine(): string { | ||
let keys = this.peerKeys(); | ||
@@ -130,3 +130,3 @@ let line = `connected to ${keys.length} peer${ | ||
// Returns many lines of printable status | ||
statusLines(): string[] { | ||
async statusLines(): Promise<string[]> { | ||
let lines = [ | ||
@@ -136,2 +136,8 @@ `public key: ${this.keyPair.getPublicKey()}`, | ||
]; | ||
for (let cname in this.channels) { | ||
lines.push(`Channel ${cname}:`); | ||
let channel = this.channels[cname]; | ||
let clines = await channel.statusLines(); | ||
lines = lines.concat(clines); | ||
} | ||
for (let peer of this.getPeers()) { | ||
@@ -148,8 +154,2 @@ lines.push(`Peer ${peer.humanID()}:`); | ||
show() { | ||
for (let line of this.statusLines()) { | ||
console.log(line); | ||
} | ||
} | ||
handleTick() { | ||
@@ -156,0 +156,0 @@ let subticks = 0; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
355744
6954