Skip to content

feat: add json metadata and storage read support#115

Merged
pchuri merged 2 commits intopchuri:mainfrom
madrover:feat/json-metadata-storage-read
Apr 24, 2026
Merged

feat: add json metadata and storage read support#115
pchuri merged 2 commits intopchuri:mainfrom
madrover:feat/json-metadata-storage-read

Conversation

@madrover
Copy link
Copy Markdown
Contributor

Description

Add machine-readable metadata and native storage read support to improve confluence-cli for automation and scripting use cases.

This PR:

  • adds confluence info --format json
  • adds confluence read <pageId> --format storage
  • enriches confluence children --format json with stable metadata fields such as id, title, type, status, spaceKey, parentId, version, and url
  • adds tests and README/help updates
  • preserves existing human-readable output for current users

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring

Testing

  • Tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Screenshots (if applicable)

Not applicable.

Additional Context

Local verification:

  • npm run lint -- --quiet
  • npm test -- --runInBand

Notes:

  • existing default text output for info, read, and children remains unchanged
  • info --format json returns a single structured object
  • read --format storage returns the page body in Confluence storage representation through the normal read path
  • children --format json now returns structured metadata records for direct and recursive listings

@madrover madrover force-pushed the feat/json-metadata-storage-read branch from b129543 to 9d819f4 Compare April 23, 2026 20:39
@pchuri
Copy link
Copy Markdown
Owner

pchuri commented Apr 24, 2026

Thanks for putting this together. The added docs and test coverage are appreciated, especially around the new JSON and storage-format flows.

Copy link
Copy Markdown
Owner

@pchuri pchuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a couple of inline notes below.

Comment thread lib/confluence-client.js Outdated
limit: limit,
// Fetch lightweight payload; content fetched on-demand when copying
expand: 'space,version'
expand: 'space,version,ancestors'
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition overall. One concern: getChildPages() is also used by children --recursive, recursive export, and copy-tree, so always requesting ancestors makes those paths fetch and retain the full ancestor chain even when they only need title/id/space. On large trees this can become a noticeable payload and memory regression. Could ancestor expansion be made opt-in for the JSON metadata path instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I changed getChildPages() so ancestor expansion is opt-in instead of always enabled. Recursive traversal now only requests ancestors for the JSON metadata path, so children --recursive, export, and copy-tree keep using the lighter payload by default.

Comment thread lib/confluence-client.js
title: raw?.title || '',
type: raw?.type || null,
status: raw?.status || null,
space,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

info --format json is positioned as machine-readable output, but this currently forwards raw.space as-is. That leaks the Cloud/DC REST shape into the public JSON contract, so scripts may see different nested fields depending on deployment or API version. I think it would be safer to normalize space here, or omit it and rely on spaceKey.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I normalized space to a stable { key, name } shape in the machine-readable page metadata instead of passing through the raw REST payload. spaceKey is still present as the flat field for scripts that want the simplest contract.

Copy link
Copy Markdown
Contributor Author

@madrover madrover left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed both inline comments: ancestor fetching is now opt-in for the JSON metadata flow, and info --format json now returns a normalized space object. Tests and lint are passing locally.

Comment thread lib/confluence-client.js Outdated
limit: limit,
// Fetch lightweight payload; content fetched on-demand when copying
expand: 'space,version'
expand: 'space,version,ancestors'
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I changed getChildPages() so ancestor expansion is opt-in instead of always enabled. Recursive traversal now only requests ancestors for the JSON metadata path, so children --recursive, export, and copy-tree keep using the lighter payload by default.

Comment thread lib/confluence-client.js
title: raw?.title || '',
type: raw?.type || null,
status: raw?.status || null,
space,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I normalized space to a stable { key, name } shape in the machine-readable page metadata instead of passing through the raw REST payload. spaceKey is still present as the flat field for scripts that want the simplest contract.

@pchuri pchuri merged commit 179fe4f into pchuri:main Apr 24, 2026
6 checks passed
github-actions Bot pushed a commit that referenced this pull request Apr 24, 2026
# [1.32.0](v1.31.1...v1.32.0) (2026-04-24)

### Features

* add json metadata and storage read support ([#115](#115)) ([179fe4f](179fe4f))
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.32.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants