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

@cdes-world/sdk-typescript

v1.2.0

Published

Cannabis Data Exchange Standard (CDES) TypeScript SDK for parsing and working with cannabis industry data

Downloads

55

Readme

CDES TypeScript SDK

Cannabis Data Exchange Standard (CDES) TypeScript library for parsing, analyzing, and working with cannabis data. Built for Power BI visuals, web applications, and any TypeScript/JavaScript project.

Features

Multi-format Parser - Parse cannabis data from Power BI DataViews, JSON, or API responses ✅ Cannabinoid Analysis - Compare profiles, find similarities, classify strains ✅ Color Mapping - Built-in therapeutic color palette (THC🔴, CBD🔵, CBN🟠, etc.) ✅ Type-Safe - Full TypeScript support with strict mode ✅ Well-Tested - Jest test suite with comprehensive coverage ✅ Zero Dependencies - Pure TypeScript, no external runtime dependencies ✅ npm Published - Installable via npm install @cdes-world/sdk-typescript

Installation

npm install @cdes-world/sdk-typescript

Quick Start

Parse Power BI Data

import { CDESParser } from "@cdes-world/sdk-typescript";

// Parse a Power BI DataView
const parsed = CDESParser.parseDataView(dataView.categorical);

console.log(`Parsed ${parsed.profiles.length} cannabinoid profiles`);
console.log(`Mode: ${parsed.parseMode}`); // "standard" or "cdes"

parsed.profiles.forEach((profile) => {
  console.log(`${profile.batchName}: ${profile.totalCannabinoids}% total`);
  profile.cannabinoids.forEach((percentage, name) => {
    console.log(`  ${name}: ${percentage}%`);
  });
});

Parse JSON Data

import { CDESParser } from "@cdes-world/sdk-typescript";

const batches = [
  { id: "batch1", name: "Strain A", thc: 20, cbd: 15, cbn: 2 },
  { id: "batch2", name: "Strain B", thc: 18, cbd: 12, cbn: 1.5 },
];

const profiles = CDESParser.parseBatchesJSON(batches);
// profiles is now CannabinoidProfile[]

Analyze & Compare Profiles

import { CDESAnalyzer, CDESParser } from "@cdes-world/sdk-typescript";

// Parse profiles
const profiles = CDESParser.parseDataView(data);

// Compare two profiles
const comparison = CDESAnalyzer.compareProfiles(
  profiles[0],
  profiles[1]
);

console.log(`Similarity: ${comparison.similarity.toFixed(1)}%`); // 0-100
console.log(`Distance: ${comparison.distance.toFixed(2)}`);

// Show differences
comparison.differences.forEach((diff, name) => {
  const sign = diff.delta > 0 ? "+" : "";
  console.log(`${name}: ${diff.val1}% → ${diff.val2}% (${sign}${diff.delta}%)`);
});

Find Similar Profiles

const targetProfile = profiles[0];
const similar = CDESAnalyzer.findSimilarProfiles(
  targetProfile,
  profiles,
  5, // max 5 results
  50 // minimum 50% similarity
);

similar.forEach((result) => {
  console.log(
    `#${result.rank}: ${result.profile.batchName} (${result.similarity.toFixed(1)}% match)`
  );
});

Classify Strains

const classification = CDESAnalyzer.classifyStrain(profile);

console.log(`Type: ${classification.type}`); // "THC-Dominant", "CBD-Dominant", etc.
console.log(`Ratio: ${classification.ratio}`); // "10.5:1 THC:CBD"
console.log(`THC: ${classification.thcContent}`); // "High", "Moderate", "Low", "Trace"
console.log(`CBD: ${classification.cbdContent}`);

Get Cannabinoid Colors

import { getCannabioidColor, STANDARD_CANNABINOIDS } from "@cdes-world/sdk-typescript";

// Get color for specific cannabinoid
const thcColor = getCannabioidColor("THC");
console.log(thcColor.hex); // "#E74C3C"
console.log(thcColor.therapeutic); // "Psychoactive, Pain Relief, Nausea"

// Access all cannabinoids
Object.entries(STANDARD_CANNABINOIDS).forEach(([name, color]) => {
  console.log(`${name}: ${color.hex} - ${color.therapeutic}`);
});

API Reference

CDESParser

Static methods for parsing cannabis data:

parseDataView(data: PowerBICategoricalData): CDESParsedData

Parse a Power BI categorical data view. Automatically detects format:

  • Standard: Batch | Cannabinoid Name | Percentage
  • CDES: Batch | THC | CBD | CBN | CBG | ...
const result = CDESParser.parseDataView(dataView.categorical);
// Returns: { profiles: CannabinoidProfile[], parseMode: "standard" | "cdes", recordsProcessed: number }

parseBatchJSON(batch: Record<string, unknown>): CannabinoidProfile

Parse a single batch object:

const profile = CDESParser.parseBatchJSON({
  id: "batch123",
  name: "OG Kush",
  thc: 20,
  cbd: 1.5,
  cbn: 0.5,
});

parseBatchesJSON(batches: Record<string, unknown>[]): CannabinoidProfile[]

Parse an array of batch objects:

const profiles = CDESParser.parseBatchesJSON(batchArray);

CDESAnalyzer

Static methods for analyzing cannabis profiles:

compareProfiles(profile1, profile2): ComparisonResult

Compare two cannabinoid profiles:

const result = CDESAnalyzer.compareProfiles(profile1, profile2);
// Returns: { profile1, profile2, distance, similarity, differences }

findSimilarProfiles(target, profiles, limit?, minSimilarity?): SimilarityResult[]

Find similar profiles:

const similar = CDESAnalyzer.findSimilarProfiles(
  targetProfile,
  allProfiles,
  10, // max results
  60  // minimum 60% similarity
);

classifyStrain(profile): StrainClassification

Classify strain type:

const classification = CDESAnalyzer.classifyStrain(profile);
// Returns: { type, thcContent, cbdContent, ratio }

scoreProfileCompleteness(profile): { score, coverage, message }

Rate profile quality:

const score = CDESAnalyzer.scoreProfileCompleteness(profile);
// Returns score 0-100, coverage %, and descriptive message

Cannabinoid Utilities

getCannabioidColor(name: string): CannabioidColor | undefined

Get color and metadata for cannabinoid:

const color = getCannabioidColor("THC");
// Returns: { hex, rgb, therapeutic, threshold }

normalizeCannabioidName(name: string): string

Normalize cannabinoid names for comparison:

normalizeCannabioidName("THC %"); // → "THC"
normalizeCannabioidName("  cbd  "); // → "CBD"

calculateEuclideanDistance(profile1, profile2): number

Calculate similarity distance between two profiles:

const distance = calculateEuclideanDistance(p1.cannabinoids, p2.cannabinoids);

Data Structures

CannabinoidProfile

interface CannabinoidProfile {
  batchId: string; // Unique batch identifier
  batchName: string; // Display name
  cannabinoids: Map<string, number>; // {name: percentage}
  totalCannabinoids: number; // Sum of all cannabinoid percentages
}

Cannabinoid Colors

Standard Cannabinoids:

| Name | Color | Hex | Therapeutic | | --- | --- | --- | --- | | THC | 🔴 | #E74C3C | Psychoactive, Pain Relief, Nausea | | CBD | 🔵 | #3498DB | Anti-inflammatory, Anxiety, Seizures | | CBN | 🟠 | #E67E22 | Sedation, Sleep, Anti-inflammatory | | CBG | 🟣 | #9B59B6 | Uplift, Focus, Appetite Stimulant | | CBC | 🟢 | #16A085 | Anti-inflammatory, Mood Support | | THCV | 🟡 | #F39C12 | Energy, Appetite Suppression, Focus | | CBDV | 🩵 | #1ABC9C | Seizure Support, Nausea |

Supported Data Formats

Power BI Standard Format

| Field | Type | Example | | --- | --- | --- | | Category 1 (Batch ID) | string | "batch-001" | | Category 2 (Cannabinoid) | string | "THC", "CBD" | | Measure (Percentage) | number | 20.5 |

CDES Format (Multiple Measures)

| Measure | Type | Example | | --- | --- | --- | | THC | number | 20.5 | | CBD | number | 15.0 | | CBN | number | 2.1 | | CBG | number | 1.0 |

JSON Batch Format

{
  "id": "batch-001",
  "name": "OG Kush",
  "strain": "OG Kush",
  "thc": 20.5,
  "cbd": 1.0,
  "cbn": 0.5,
  "cbg": 0.2,
  "cbc": 0.1,
  "thcv": 0.3,
  "cbdv": 0.0
}

Testing

Run the Jest test suite:

npm test

Generate coverage report:

npm test -- --coverage

Building

Build TypeScript to JavaScript:

npm run build

Output files go to dist/:

  • dist/index.js - CommonJS bundle
  • dist/index.d.ts - TypeScript definitions
  • dist/models.js, dist/cannabinoids.js, etc. - Individual modules

Publishing to npm

npm version patch # or minor, major
npm run build
npm publish

Usage in Power BI Visual

import { CDESParser, CDESAnalyzer, getCannabioidColor } from "@cdes-world/sdk-typescript";

export class CannabinoidVisual implements IVisual {
  public update(options: VisualUpdateOptions) {
    // Parse Power BI data using SDK
    const parsed = CDESParser.parseDataView(
      options.dataViews[0].categorical
    );

    // Use cannabinoid utilities
    parsed.profiles.forEach((profile) => {
      profile.cannabinoids.forEach((percentage, name) => {
        const color = getCannabioidColor(name);
        // Render using color.hex, etc.
      });
    });
  }
}

Contributing

Contributions welcome! Please:

  1. Write tests for new features
  2. Follow TypeScript best practices
  3. Update README with API changes
  4. Use conventional commit messages

License

MIT - Acidni LLC

Support


Made by Acidni LLC for the cannabis data ecosystem 🌿