Skip to content

Commit b10c306

Browse files
committed
remove hardcoded rootnodeid from resolvepath, adjust return types, add test
1 parent f0c9e76 commit b10c306

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

@types/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ export declare interface NodeSession extends Session {
325325
refreshNode(repository: TypedID|string, branch: TypedID|string, node: TypedID|string, callback?: ResultCb<void>): Promise<void>
326326
changeNodeQName(repository: TypedID|string, branch: TypedID|string, node: TypedID|string, newQName: string, callback?: ResultCb<Object>): Promise<Object>
327327
nodeTree(repository: TypedID|string, branch: TypedID|string, node: TypedID|string, config?: TreeConfig, callback?: ResultCb<TreeElement>): Promise<TreeElement>
328-
resolveNodePath(repository: TypedID|string, branch: TypedID|string, node: TypedID|string, callback?: ResultCb<{path: string}>): Promise<{path: string}>
328+
resolveNodePath(repository: TypedID|string, branch: TypedID|string, node: TypedID|string, callback?: ResultCb<{path: string}>): Promise<string>
329329
resolveNodePaths(repository: TypedID|string, branch: TypedID|string, node: TypedID|string, callback?: ResultCb<{[id: string]: string}>): Promise<{[id: string]: string}>
330330
traverseNode(repository: TypedID|string, branch: TypedID|string, node: TypedID|string, config: Object, callback?: ResultCb<TraversalResult>): Promise<TraversalResult>
331331
uploadAttachment(repository: TypedID|string, branch: TypedID|string, node: TypedID|string, attachmentId: string, file: File, mimeType: string, filename?: string, callback?: ResultCb<void>): Promise<void>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cloudcms",
3-
"version": "0.2.7",
3+
"version": "0.2.8",
44
"repository": {
55
"type": "git",
66
"url": "git://github.com/gitana/cloudcms-javascript-driver.git"

src/session/default/methods/node.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -504,18 +504,17 @@ module.exports = function(Session)
504504
* @param node
505505
* @returns {*}
506506
*/
507-
resolveNodePath(repository, branch, node)
507+
async resolveNodePath(repository, branch, node)
508508
{
509509
var repositoryId = this.acquireId(repository);
510510
var branchId = this.acquireId(branch);
511511
var nodeId = this.acquireId(node);
512512
var callback = this.extractOptionalCallback(arguments);
513513

514514
var qs = {};
515-
//qs.rootNodeId = "821c40ab613d9b5bcbbc656b62229301";
516-
qs.rootNodeId = "r:root";
517515

518-
return this.get("/repositories/" + repositoryId + "/branches/" + branchId + "/nodes/" + nodeId + "/path", qs, callback);
516+
var result = await this.get("/repositories/" + repositoryId + "/branches/" + branchId + "/nodes/" + nodeId + "/path", qs, callback);
517+
return result.path;
519518
};
520519

521520
/**
@@ -527,14 +526,15 @@ module.exports = function(Session)
527526
* @param node
528527
* @returns {*}
529528
*/
530-
resolveNodePaths(repository, branch, node)
529+
async resolveNodePaths(repository, branch, node)
531530
{
532531
var repositoryId = this.acquireId(repository);
533532
var branchId = this.acquireId(branch);
534533
var nodeId = this.acquireId(node);
535534
var callback = this.extractOptionalCallback(arguments);
536535

537-
return this.get("/repositories/" + repositoryId + "/branches/" + branchId + "/nodes/" + nodeId + "/paths", {}, callback);
536+
var result = await this.get("/repositories/" + repositoryId + "/branches/" + branchId + "/nodes/" + nodeId + "/paths", {}, callback);
537+
return result.paths;
538538
};
539539

540540
/**

test/node/node11.ts

+7
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ describe('node11', function() {
5555
var n7 = await session.readNode(repository, branchId, "root", "/folder2/folder12/folder111/node7");
5656
var n8 = await session.readNode(repository, branchId, "root", "/folder2/folder12/folder112/node8");
5757

58+
// test node path
59+
var n8Paths = await session.resolveNodePaths(repository, branchId, n8);
60+
assert.isAbove(Object.keys(n8Paths).length, 0);
61+
62+
var n8Path = await session.resolveNodePath(repository, branchId, n8);
63+
assert.equal("/folder2/folder12/folder112/node8", n8Path);
64+
5865
// verify nodes exist
5966
assert.exists(n1);
6067
assert.exists(n2);

0 commit comments

Comments
 (0)