Files
wehub-resource-sync 9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:39:48 +08:00

35 lines
1.7 KiB
JavaScript

import { cli, Strategy } from '@jackwener/opencli/registry';
import { atlassianRequest, parseLimit, queryString, requireNonEmptyRows, requireString } from '../_atlassian/shared.js';
import { confluenceConfig, confluenceResults, normalizeSearchResult, withSpaceCql } from './shared.js';
cli({
site: 'confluence',
name: 'search',
access: 'read',
description: 'Search Confluence content with CQL',
domain: 'atlassian.net',
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'cql', positional: true, required: true, help: 'CQL query, e.g. "type = page and title ~ \\"RCA\\""' },
{ name: 'space', type: 'string', help: 'Limit search to a Confluence space key' },
{ name: 'limit', type: 'int', default: 20, help: 'Max results to return (1-100)' },
],
columns: ['id', 'title', 'type', 'spaceKey', 'status', 'lastModified', 'url'],
func: async (args) => {
const config = confluenceConfig();
const cql = withSpaceCql(requireString(args.cql, 'CQL'), args.space);
const limit = parseLimit(args.limit, 20, 100, 'confluence limit');
// CQL search is still exposed through Confluence REST v1 for Cloud;
// page CRUD uses v2 where available.
const path = `/rest/api/search${queryString({ cql, limit })}`;
const data = await atlassianRequest(config, path, { label: 'confluence search' });
const results = confluenceResults(data, 'confluence search');
return requireNonEmptyRows(
results.map((result) => normalizeSearchResult(result, config)),
'confluence search',
`No Confluence content matched "${cql}".`,
);
},
});