pathchain 1.0.53 → 1.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/getter.js +11 -119
- package/package.json +1 -1
- package/proto/link.proto +5 -5
package/getter.js
CHANGED
|
@@ -188,39 +188,39 @@ function getNodeObj(xnode, xauthor) {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
|
|
191
|
-
/**
|
|
192
|
-
* [Function that recieves a
|
|
191
|
+
/** getLinkObj
|
|
192
|
+
* [Function that recieves a link hash and returns the link object]
|
|
193
193
|
*
|
|
194
|
-
* @param {string}
|
|
194
|
+
* @param {string} xlink (required)
|
|
195
195
|
*
|
|
196
196
|
* @return void
|
|
197
197
|
*/
|
|
198
|
-
function
|
|
198
|
+
function getLinkObj(xlink, xauthor) {
|
|
199
199
|
|
|
200
200
|
if(xauthor != ""){
|
|
201
201
|
xauthor = xauthor + '/';
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
// LOADING PB
|
|
205
|
-
var
|
|
205
|
+
var link_pb = pb(fs.readFileSync('node_modules/pathchain/proto/link.proto'))
|
|
206
206
|
|
|
207
207
|
// NOT FOUND EXCEPTION
|
|
208
208
|
var fileContents;
|
|
209
209
|
try {
|
|
210
|
-
fileContents = fs.readFileSync("files/" + xauthor + "
|
|
210
|
+
fileContents = fs.readFileSync("files/" + xauthor + "links/" + xlink);
|
|
211
211
|
} catch (err) {
|
|
212
212
|
if (err.code === 'ENOENT') {
|
|
213
|
-
return "
|
|
213
|
+
return "Link not found";
|
|
214
214
|
} else {
|
|
215
215
|
throw err;
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
// DECODING NODE
|
|
220
|
-
var
|
|
221
|
-
var
|
|
220
|
+
var link_enc = fileContents
|
|
221
|
+
var link_obj = link_pb.link.decode(link_enc)
|
|
222
222
|
|
|
223
|
-
return
|
|
223
|
+
return link_obj;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
|
|
@@ -260,114 +260,6 @@ function getPathObj(xpath, xauthor) {
|
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
|
|
263
|
-
/** getPathlinkObj
|
|
264
|
-
* [Function that recieves a pathlink hash and returns the pathlink object]
|
|
265
|
-
*
|
|
266
|
-
* @param {string} xpathlink (required)
|
|
267
|
-
*
|
|
268
|
-
* @return void
|
|
269
|
-
*/
|
|
270
|
-
function getPathlinkObj(xpathlink, xauthor) {
|
|
271
|
-
|
|
272
|
-
if(xauthor != ""){
|
|
273
|
-
xauthor = xauthor + '/';
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// LOADING PB
|
|
277
|
-
var pathlink_pb = pb(fs.readFileSync('node_modules/pathchain/proto/pathlink.proto'))
|
|
278
|
-
|
|
279
|
-
// NOT FOUND EXCEPTION
|
|
280
|
-
var fileContents;
|
|
281
|
-
try {
|
|
282
|
-
fileContents = fs.readFileSync("files/" + xauthor + "pathlinks/" + xpathlink);
|
|
283
|
-
} catch (err) {
|
|
284
|
-
if (err.code === 'ENOENT') {
|
|
285
|
-
return "Pathlink not found";
|
|
286
|
-
} else {
|
|
287
|
-
throw err;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// DECODING PATHLINK
|
|
292
|
-
var pathlink_enc = fileContents
|
|
293
|
-
var pathlink_obj = pathlink_pb.pathlink.decode(pathlink_enc)
|
|
294
|
-
|
|
295
|
-
return pathlink_obj;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
/** getTreeObj
|
|
300
|
-
* [Function that recieves a tree hash and returns the tree object]
|
|
301
|
-
*
|
|
302
|
-
* @param {string} xtree (required)
|
|
303
|
-
*
|
|
304
|
-
* @return void
|
|
305
|
-
*/
|
|
306
|
-
function getTreeObj(xtree, xauthor) {
|
|
307
|
-
|
|
308
|
-
if(xauthor != ""){
|
|
309
|
-
xauthor = xauthor + '/';
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// LOADING PB
|
|
313
|
-
var tree_pb = pb(fs.readFileSync('node_modules/pathchain/proto/tree.proto'))
|
|
314
|
-
|
|
315
|
-
// NOT FOUND EXCEPTION
|
|
316
|
-
var fileContents;
|
|
317
|
-
try {
|
|
318
|
-
fileContents = fs.readFileSync("files/" + xauthor + "trees/" + xtree);
|
|
319
|
-
} catch (err) {
|
|
320
|
-
if (err.code === 'ENOENT') {
|
|
321
|
-
return "Tree not found";
|
|
322
|
-
} else {
|
|
323
|
-
throw err;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
// DECODING TREE
|
|
328
|
-
var tree_enc = fileContents
|
|
329
|
-
var tree_obj = tree_pb.tree.decode(tree_enc)
|
|
330
|
-
|
|
331
|
-
return tree_obj;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
/** getTreelinkObj
|
|
336
|
-
* [Function that recieves a treelink hash and returns the treelink object]
|
|
337
|
-
*
|
|
338
|
-
* @param {string} xtreelink (required)
|
|
339
|
-
*
|
|
340
|
-
* @return void
|
|
341
|
-
*/
|
|
342
|
-
function getTreelinkObj(xtreelink, xauthor) {
|
|
343
|
-
|
|
344
|
-
if(xauthor != ""){
|
|
345
|
-
xauthor = xauthor + '/';
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
// LOADING PB
|
|
349
|
-
var treelink_pb = pb(fs.readFileSync('node_modules/pathchain/proto/treelink.proto'))
|
|
350
|
-
|
|
351
|
-
// NOT FOUND EXCEPTION
|
|
352
|
-
var fileContents;
|
|
353
|
-
try {
|
|
354
|
-
fileContents = fs.readFileSync("files/" + xauthor + "treelinks/" + xtreelink);
|
|
355
|
-
} catch (err) {
|
|
356
|
-
if (err.code === 'ENOENT') {
|
|
357
|
-
return "Treelink not found";
|
|
358
|
-
} else {
|
|
359
|
-
throw err;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// DECODING TREELINK
|
|
364
|
-
var treelink_enc = fileContents
|
|
365
|
-
var treelink_obj = treelink_pb.treelink.decode(treelink_enc)
|
|
366
|
-
|
|
367
|
-
return treelink_obj;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
|
|
371
263
|
/** getLabelObj
|
|
372
264
|
* [Function that recieves a label hash and returns the label object]
|
|
373
265
|
*
|
|
@@ -404,4 +296,4 @@ function getLabelObj(xlabel, xauthor) {
|
|
|
404
296
|
}
|
|
405
297
|
|
|
406
298
|
|
|
407
|
-
module.exports = { getCurrentDate, getMomentObj, getPioneerObj, getSecretObj, getEntityObj, getNodeObj,
|
|
299
|
+
module.exports = { getCurrentDate, getMomentObj, getPioneerObj, getSecretObj, getEntityObj, getNodeObj, getLinkObj, getPathObj, getPathlinkObj, getTreeObj, getTreelinkObj, getLabelObj }
|
package/package.json
CHANGED
package/proto/link.proto
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
syntax = "proto3";
|
|
2
2
|
|
|
3
|
-
message
|
|
3
|
+
message link {
|
|
4
4
|
required string register = 1;
|
|
5
5
|
required string author = 2;
|
|
6
|
-
required string
|
|
7
|
-
required string
|
|
8
|
-
required string
|
|
9
|
-
required string
|
|
6
|
+
required string prev = 3;
|
|
7
|
+
required string next = 4;
|
|
8
|
+
required string target = 5;
|
|
9
|
+
required string ancestor = 6;
|
|
10
10
|
required string tag = 7;
|
|
11
11
|
}
|