feat(children): add --space to list a whole space - #124
Conversation
|
Follow-up from a code-review pass, three commits on top: A failing The Offset paging on the root-pages route is measured rather than assumed.
|
Records what was measured for #98: the v1 depth=root route and the fact that its rows are already ChildNode-shaped, that a space can have more than one root page (AIM has two, so walking from homepageId would silently drop a subtree), that an unknown key must be detected by resolving it rather than by reading a 404 body, and that a folder created with no parentId lands under the homepage rather than at the root -- which resolves an Unverified bullet in folders.md.
client.ListSpaceRootPages reads the v1 depth=root collection, whose rows are already ChildNode-shaped, and pagetree.WalkSpace seeds the existing traversal with them. The seed is the space's root *pages*, not its homepage: a space can have several roots, so starting from homepageId would drop one and its whole subtree. A root page reports ParentID "", since the space it sits in is not a node. Walk and WalkSpace now share one walker, so the depth rule and the visited guard exist in one copy.
PAGE becomes optional and exactly one of PAGE / --space is required, checked before credentials are resolved. Depth 1 under --space is the space's root pages -- usually just the homepage, which is why human output adds a line pointing at --depth when the caller left it alone. An unknown key is reported as a typo (exit 2, VALIDATION) after resolving it with the v2 spaces route, rather than by reading the v1 404's body: a rejected credential answers 404 too. childrenResult.parent_id widens to stringOrNull, since a page at a space root hangs off no node and the space is not one.
README gains a --space subsection under children (what depth 1 means, the null parent_id, the unknown-key error) and the space-key resolve row in the scope table now names children. CLAUDE.md records the design in the children and pagetree bullets, and corrects search's claim to being the only Flags().Changed caller in cmd/.
Two things a review caught, both about what lands on stdout: A --space walk that fails names no page, so reporting it as a results[0] failure put the space key in page_id -- an id that resolves to nothing. It now writes an error object on stderr, as find and search already do for the same reason. The --depth hint moves to stderr behind a new ui.Hint, so `children --space ENG | awk` still gets nothing but table rows. Also pins the root-page route's offset paging, measured against AIM: start is honoured and a past-the-end page is empty, so listV1 terminates. A route that ignored start would have re-read page one forever.
5c92840 to
61e2974
Compare
Closes #98.
childrengrows a--space KEYflag that lists a whole space instead of a page, so "show me everything in this space" no longer requires knowing CQL.PAGEbecomes optional; exactly one ofPAGE/--spaceis required, checked before credentials are resolved.What depth 1 means, and why it isn't the homepage's children
Depth 1 under
--spaceis the space's root pages, so the homepage is a row and its children are depth 2. Seeding the walk from the space'shomepageIdwas the obvious design and it is wrong: a space can have more than one root page (AIMon our instance has two, andmarkfluence createwithparent: nullproduces exactly that shape), so starting at the homepage would drop a root page and its entire subtree — silently, the same way v2/childrendrops folders.There is no root-level folder to miss:
POST /wiki/api/v2/folderswith aspaceIdand noparentIdcreates the folder under the homepage, reportingparentType: "page". That also resolves an open "Unverified" bullet indocs/confluence/folders.md.All of the probing behind this — the v1
depth=rootroute and the fact that its bare rows are alreadyChildNode-shaped, archived roots being excluded, the unknown-key 404, the four routes that do not list root folders, and why the tempting flat/api/v2/spaces/{id}/pagessweep is unusable — is written up in the newdocs/confluence/spaces.md.Other decisions worth a look
ResolveSpaceIDruns first and an unknown key is a usage error (exit 2,VALIDATION) worded exactly asfind/searchword it. The v1 route's own 404 names the key, but a rejected credential is also a 404, and that is the misreportRejectedCredentialexists to prevent. The cost is one request whose result goes unused.parent_idwidens tostringOrNull. A root page hangs off no node, and the space is not one, sonullrather than""or the space id.--depthreminder in human output. A space's top level is usually one row, which reads like the whole answer; the line prints only when--depthwas left at its default, and--jsonnever sees it.--spaceis a key, not a URL, matchingfindandsearch.pagetree.Walkand the newWalkSpacenow share onewalker, so the depth rule and the visited guard exist in one copy.Verification
make checkis green. New tests cover the route (path,depth=root, a~personalkey escaped),WalkSpace(two roots, folder descent,ParentID "", the depth bound costing no requests below it), and the command (both usage errors, unknown key, the hint's presence and absence,parent_id: nullin--json).Live, against
mozilla-hub:The 36 rows are 33 current pages plus 3 folders; the space's 34th page is archived, which
depth=rootand the v1 child routes both exclude.Not done here
The issue's alternative suggestion — documenting the CQL space-listing pattern in
search --help— is deliberately skipped: pointing users at CQL for the taskchildren --spacenow covers works against the point.search --helpis unchanged.