//native
type Gitbook = {
token: string;
};
/**
* List all public integrations along with private ones trusted by the specific org.
*
*/
export async function main(
auth: Gitbook,
organizationId: string,
page: string | undefined,
limit: string | undefined,
search: string | undefined,
category:
| "analytics"
| "collaboration"
| "content"
| "gitsync"
| "marketing"
| "visitor-auth"
| "other"
| undefined,
blockDomain: string | undefined,
blocks: string | undefined,
contentSources: string | undefined,
owner: string | undefined,
scope:
| "space:views:read"
| "space:content:read"
| "space:content:write"
| "space:metadata:read"
| "space:metadata:write"
| "space:script:inject"
| "space:script:cookies"
| "space:git:sync"
| "space:visitor:auth"
| "site:metadata:read"
| "site:views:read"
| "site:script:inject"
| "site:script:cookies"
| "site:visitor:auth"
| "site:adaptive:read"
| "site:adaptive:write"
| "openapi:read"
| "openapi:write"
| "conversations:ingest"
| undefined,
target: "all" | "site" | "space" | "organization" | undefined,
) {
const url = new URL(`https://api.gitbook.com/v1/orgs/${organizationId}/integrations`);
for (const [k, v] of [
["page", page],
["limit", limit],
["search", search],
["category", category],
["blockDomain", blockDomain],
["blocks", blocks],
["contentSources", contentSources],
["owner", owner],
["scope", scope],
["target", target],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago