confluence-cli 2.3.1 → 2.4.0

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/README.md CHANGED
@@ -466,7 +466,14 @@ confluence export 123456789 --skip-attachments
466
466
 
467
467
  ### List Spaces
468
468
  ```bash
469
+ # Default: up to 500 spaces (paginated automatically across requests)
469
470
  confluence spaces
471
+
472
+ # Increase the cap when your tenant has more than 500 spaces
473
+ confluence spaces --limit 2000
474
+
475
+ # Fetch every space, regardless of how many pages it takes
476
+ confluence spaces --all
470
477
  ```
471
478
 
472
479
  ### List Child Pages
@@ -691,7 +698,7 @@ confluence stats
691
698
  | `read <pageId_or_url>` | Read page content | `--format <html\|text\|storage\|markdown>` |
692
699
  | `info <pageId_or_url>` | Get page information | `--format <text\|json>` |
693
700
  | `search <query>` | Search for pages | `--limit <number>` |
694
- | `spaces` | List available spaces | `--limit <number>` |
701
+ | `spaces` | List available spaces | `--limit <number>`, `--all` |
695
702
  | `find <title>` | Find a page by its title | `--space <spaceKey>` |
696
703
  | `children <pageId>` | List child pages of a page | `--recursive`, `--max-depth <number>`, `--format <list\|tree\|json>`, `--show-url`, `--show-id` |
697
704
  | `create <title> <spaceKey>` | Create a new page or folder | `--content <string>`, `--file <path>`, `--format <storage\|html\|markdown>`, `--type <page\|folder>` |
package/bin/confluence.js CHANGED
@@ -154,15 +154,17 @@ program
154
154
  program
155
155
  .command('spaces')
156
156
  .description('List Confluence spaces')
157
- .option('-l, --limit <limit>', 'Limit number of results', '500')
157
+ .option('-l, --limit <limit>', 'Maximum total spaces to return across paginated requests', '500')
158
+ .option('--all', 'Fetch every space, paginating through all results (overrides --limit)')
158
159
  .action(async (options) => {
159
160
  const analytics = new Analytics();
160
161
  try {
161
162
  const config = getConfig(getProfileName());
162
163
  const client = new ConfluenceClient(config);
163
- const spaces = await client.getSpaces(parseInt(options.limit));
164
-
165
- console.log(chalk.blue('Available spaces:'));
164
+ const maxResults = options.all ? null : parseInt(options.limit);
165
+ const spaces = await client.getSpaces(maxResults);
166
+
167
+ console.log(chalk.blue(`Available spaces (${spaces.length}):`));
166
168
  spaces.forEach(space => {
167
169
  console.log(`${chalk.green(space.key)} - ${space.name}`);
168
170
  });
@@ -437,20 +437,58 @@ class ConfluenceClient {
437
437
  }
438
438
 
439
439
  /**
440
- * Get spaces
440
+ * List a single page of spaces with pagination metadata
441
441
  */
442
- async getSpaces(limit = 500) {
442
+ async listSpaces(options = {}) {
443
+ const limit = this.parsePositiveInt(options.limit, 500);
444
+ const start = this.parsePositiveInt(options.start, 0);
445
+
443
446
  const response = await this.client.get('/space', {
444
- params: {
445
- limit
446
- }
447
+ params: { limit, start }
447
448
  });
448
449
 
449
- return response.data.results.map(space => ({
450
- key: space.key,
451
- name: space.name,
452
- type: space.type
453
- }));
450
+ const results = Array.isArray(response.data?.results)
451
+ ? response.data.results.map(space => ({
452
+ key: space.key,
453
+ name: space.name,
454
+ type: space.type
455
+ }))
456
+ : [];
457
+
458
+ return {
459
+ results,
460
+ nextStart: this.parseNextStart(response.data?._links?.next)
461
+ };
462
+ }
463
+
464
+ /**
465
+ * Get spaces, paginating through results until maxResults is reached or
466
+ * the server stops returning a `_links.next`. Pass `null` to fetch every space.
467
+ */
468
+ async getSpaces(maxResults = 500, options = {}) {
469
+ const cap = maxResults === null || maxResults === undefined
470
+ ? null
471
+ : this.parsePositiveInt(maxResults, 500);
472
+ const pageSize = this.parsePositiveInt(options.pageSize, 500);
473
+ let start = this.parsePositiveInt(options.start, 0);
474
+ const spaces = [];
475
+
476
+ let hasNext = true;
477
+ while (hasNext) {
478
+ if (cap !== null && spaces.length >= cap) break;
479
+ const requestLimit = cap === null
480
+ ? pageSize
481
+ : Math.min(pageSize, cap - spaces.length);
482
+ const page = await this.listSpaces({ limit: requestLimit, start });
483
+ spaces.push(...page.results);
484
+
485
+ hasNext = page.nextStart !== null && page.nextStart !== undefined;
486
+ if (hasNext) {
487
+ start = page.nextStart;
488
+ }
489
+ }
490
+
491
+ return cap !== null ? spaces.slice(0, cap) : spaces;
454
492
  }
455
493
 
456
494
  /**
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "confluence-cli",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "confluence-cli",
9
- "version": "2.3.1",
9
+ "version": "2.4.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "axios": "^1.15.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "confluence-cli",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "description": "A command-line interface for Atlassian Confluence with page creation and editing capabilities",
5
5
  "main": "index.js",
6
6
  "bin": {