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

@osdk/osdk-docs-context

v0.7.0

Published

OSDK Documentation Context utilities and examples registry

Downloads

3,345

Readme

@osdk/osdk-docs-context

A public NPM package that provides structured access to OSDK TypeScript code examples organized by version, with template variations for different usage contexts.

Purpose

This package provides OSDK code examples in two formats:

  • Flat structure: Direct access when you know exact template names
  • Nested structure: Hierarchical organization with variations grouped under base templates

What are Template Variations?

Many OSDK templates have different code examples based on properties or conditions. For example:

  • derivedPropertyNumericExpression (base template)
    • #isUnary variation - shows unary numeric operations
    • ^isUnary variation - shows non-unary numeric operations

This allows you to see different code contexts for the same concept.

Installation

npm install @osdk/osdk-docs-context
# or
pnpm add @osdk/osdk-docs-context

Usage

Basic Example Access

import {
  NestedOsdkExamplesContext,
  OSDK_DOCS_CONTEXT,
} from "@osdk/osdk-docs-context";

// Get all available OSDK versions
const versions = NestedOsdkExamplesContext.getAvailableVersions();

// Get a simple template (no variations)
const example = NestedOsdkExamplesContext.getExample("2.4.0", [
  "loadGeotimeSeriesPointsSnippet",
]);

// Get a template variation
const variation = NestedOsdkExamplesContext.getExample("2.4.0", [
  "derivedPropertyNumericExpression",
  "#isUnary",
]);

Working with Template Variations

// Check if a template has variations
const hasVariations = NestedOsdkExamplesContext.hasVariations(
  "2.4.0",
  "derivedPropertyNumericExpression",
);

// Get all variations for a template
const variations = NestedOsdkExamplesContext.getVariations(
  "2.4.0",
  "derivedPropertyNumericExpression",
);
// Returns: ["#isUnary", "^isUnary"]

// Access specific variations
variations.forEach(variation => {
  const code = NestedOsdkExamplesContext.getExample("2.4.0", [
    "derivedPropertyNumericExpression",
    variation,
  ]);
  console.log(`${variation}:`, code?.code);
});

Search and Discovery

// Search examples across all versions
const results = NestedOsdkExamplesContext.searchExamples("numeric");

// Search within a specific version
const versionResults = NestedOsdkExamplesContext.searchExamples(
  "load",
  "2.4.0",
);

Version Compatibility

The package implements semantic version fallback - newer versions include examples from older compatible versions:

// 2.4.0 includes examples from 2.0.0, 2.1.0, and 2.4.0
const examples240 = NestedOsdkExamplesContext.getBaseExamplesForVersion(
  "2.4.0",
);

// 2.1.0 includes examples from 2.0.0 and 2.1.0 (but NOT 2.4.0)
const examples210 = NestedOsdkExamplesContext.getBaseExamplesForVersion(
  "2.1.0",
);

Data Structure

Each example includes:

  • filePath: Location of the source file
  • code: The actual TypeScript code
  • Version and variation metadata
{
  "2.4.0": {
    "examples": {
      "loadGeotimeSeriesPointsSnippet": {
        "filePath": "examples/typescript/2.4.0/loadGeotimeSeriesPointsSnippet.ts",
        "code": "// TypeScript code here..."
      },
      "derivedPropertyNumericExpression": {
        "#isUnary": {
          "filePath": "examples/typescript/2.4.0/derivedPropertyNumericExpression_#isUnary.ts",
          "code": "// Unary operation code..."
        },
        "^isUnary": {
          "filePath": "examples/typescript/2.4.0/derivedPropertyNumericExpression_^isUnary.ts",
          "code": "// Non-unary operation code..."
        }
      }
    }
  }
}

MCP Server Integration

This package is designed for MCP servers and external tools:

// Perfect for MCP servers - stable public API
import { NestedOsdkExamplesContext } from "@osdk/osdk-docs-context";

function getOsdkExamples(version: string, templateName?: string) {
  if (templateName) {
    return NestedOsdkExamplesContext.getExample(version, [templateName]);
  }
  return NestedOsdkExamplesContext.getExamplesWithVersionInfo(version);
}

Build

pnpm build

Generates ES modules, CommonJS, and TypeScript declarations in the build/ directory.