import Link from 'next/link';
import { createHighlighter } from 'shiki';
import {
getApiGroups,
getGrantIndex,
getOperationCount,
getSdkLanguages,
getSecurityScheme,
} from '@/lib/api-reference';
import { MethodBadge, methodStyle } from './method-badge';
import { Tabs } from './tabs';
/**
* Overview surfaces for the API reference. Every list here is derived
* from the committed OpenAPI document — resource groups from
* `x-docs-groups`, credential names from the security schemes, and the
* capability tables by inverting each operation's `x-required-*`. A new
* operation or group in the contract shows up here with no edit.
*/
const CARD = 'border-cp-border overflow-hidden rounded-[14px] border bg-white';
const installHighlighter = createHighlighter({
themes: ['material-theme-palenight'],
langs: ['sh', 'groovy'],
});
/**
* Install commands per SDK, sharing the reference's language switcher —
* so choosing a language here also settles every operation page's
* examples, and arriving from the docs landing lands on your language.
*/
export async function ApiInstall() {
const languages = getSdkLanguages();
const highlighter = await installHighlighter;
const blocks = languages.map((language) => ({
...language,
html: highlighter.codeToHtml(language.install, {
lang: language.installFence,
theme: 'material-theme-palenight',
}),
}));
return (
block.label)} storageKey="cloudpdf-sdk-language">
{blocks.map((block) => (
))}
);
}
/** The reference's resource groups, each listing the operations it holds. */
export function ApiResources() {
const groups = getApiGroups().filter((group) => group.operations.length > 0);
return (
);
}
export function ApiOperationCount() {
return <>{getOperationCount()}>;
}
const CREDENTIAL_ORDER = ['apiToken', 'tenantToken', 'docToken', 'uploadToken'] as const;
const CREDENTIAL_HOLDER: Record = {
apiToken: 'Your server environment',
tenantToken: 'Your backend',
docToken: "The end user's browser",
uploadToken: "The end user's browser, to upload",
};
/**
* The credentials as a ladder. Authority mints only downward, and
* each rung's blast radius shrinks as it moves closer to the browser —
* the one idea that makes every per-operation auth rule obvious.
*/
export function ApiCredentials() {
return (