npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gravitek/confluence-mirror-core

v0.2.0

Published

Core logic for Confluence page rendering - API client, ADF processing, media handling. Unofficial, not affiliated with Atlassian.

Readme

confluence-mirror-core

Core logic for Confluence page rendering - framework agnostic.

Installation

npm install confluence-mirror-core

Features

  • Confluence REST API Client - Authenticate and fetch pages
  • ADF Processing - Parse Atlas Document Format
  • Media Processing - Extract and rewrite media URLs
  • TOC Extraction - Generate table of contents from headings
  • TypeScript Support - Full type definitions
  • Zero Dependencies - Pure logic, no UI framework dependencies

Quick Start

import { 
  ConfluenceClient, 
  processADFWithMedia, 
  processADFWithTOC 
} from 'confluence-mirror-core';

// Initialize client
const client = new ConfluenceClient(
  "https://your-domain.atlassian.net",
  "[email protected]", 
  "your-api-key"
);

// Fetch a page
const page = await client.getPage("page-id");

// Process ADF with media URLs
const processedContent = await processADFWithMedia(
  JSON.parse(page.body.atlas_doc_format.value),
  page.body.storage?.value || "",
  "page-id"
);

// Extract table of contents
const { enrichedDocument, tableOfContents } = processADFWithTOC(processedContent);

API Reference

ConfluenceClient

class ConfluenceClient {
  constructor(baseUrl: string, email: string, apiKey: string)
  
  async getPage(pageId: string, includeChildren?: boolean): Promise<ConfluencePage>
  async getChildPages(pageId: string): Promise<ConfluenceChildPage[]>
  async getCurrentUser(): Promise<any>
  
  static extractPageIdFromUrl(url: string): string | null
}

Processing Functions

// Media processing
async function processADFWithMedia(
  adfDocument: ADFDocument,
  storageHtml: string,
  pageId: string
): Promise<ADFDocument>

// TOC processing  
function processADFWithTOC(adfDocument: ADFDocument): {
  enrichedDocument: ADFDocument;
  tableOfContents: TocItem[];
}

// Utility functions
function extractTextFromADFNodes(nodes: ADFNode[]): string
function generateSlug(text: string, existingSlugs?: Set<string>): string

Types

interface ConfluencePage {
  id: string;
  title: string;
  body: {
    atlas_doc_format?: { value: string };
    storage?: { value: string; representation: string };
  };
  version: { number: number };
  space: { key: string; name: string };
  _links: { webui: string };
  children?: { page?: { results: ConfluenceChildPage[]; size: number } };
}

interface ADFDocument {
  version: number;
  type: "doc";
  content: ADFNode[];
}

interface TocItem {
  id: string;
  title: string;
  level: number;
}

Error Handling

import { ConfluenceApiError } from 'confluence-mirror-core';

try {
  const page = await client.getPage("invalid-id");
} catch (error) {
  if (error instanceof ConfluenceApiError) {
    console.log(`API Error ${error.statusCode}: ${error.message}`);
  }
}

Contributing

This package contains pure logic with no UI dependencies. When contributing:

  1. Keep functions pure and testable
  2. Maintain TypeScript strict mode compliance
  3. Add tests for new functionality
  4. Update type definitions as needed

License

Apache-2.0