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

@tfw.in/structura-sdk

v0.1.0

Published

TypeScript SDK for Saral Structura, providing Zod schemas and validation for document processing outputs.

Readme

TypeScript SDK for Saral Document Validation

This SDK provides Zod schemas and a validator function to parse and validate JSON data structured according to the Saral DocumentOutput format. It's designed to ensure that your document data conforms to the expected schema before further processing.

Installation

To install the SDK, use npm or yarn:

npm install @tfw.in/structura/sdk

or

yarn add @tfw.in/structura/sdk

Basic Usage

The primary function provided by this SDK is parseAndValidateDocumentOutput. You can use it to validate your JSON data.

import { parseAndValidateDocumentOutput, ValidationResult, DocumentOutput } from '@tfw.in/structura/sdk';

// Assuming jsonData is a string containing your JSON data
const jsonData: string = '{"version": "0.0.1", "blocks": [...], ...}';

const result: ValidationResult = parseAndValidateDocumentOutput(jsonData);

if (result.isValid) {
  console.log("Validation successful!");
  const documentOutput: DocumentOutput | null = result.data;
  // Use documentOutput for further processing
  if (documentOutput) {
    console.log("Document Version:", documentOutput.version);
  }
} else {
  console.error("Validation failed:");
  result.errors?.forEach(error => console.error("- ", error));
}

Available Exports

This SDK exports the following:

Validator Function

  • parseAndValidateDocumentOutput(jsonData: string): ValidationResult

Interfaces

  • ValidationResult: { data: DocumentOutput | null; isValid: boolean; errors: string[]; }

Zod Schemas and Inferred Types

The SDK exports various Zod schemas and their corresponding TypeScript types. These are the source of truth for the data structures.

  • BlockTypesEnumSchema & BlockTypesEnumType (Zod schema and its inferred type for the BlockTypes enum)
  • PolygonBoxSchema & PolygonBox
  • BlockIdSchema & BlockId
  • BlockMetadataSchema & BlockMetadata
  • BlockSchema & Block (Base block schema)
  • TableCellSchema & TableCell
  • MergedTableSchema & MergedTable
  • BlockOutputSchema & BlockOutput (Schema for individual blocks within the document output)
  • DocumentOutputSchema & DocumentOutput (Top-level schema for the entire document output)

Enums

  • BlockTypes (The TypeScript enum itself)

You can import these directly as needed:

import {
  DocumentOutputSchema,
  DocumentOutput,
  BlockOutputSchema,
  BlockOutput,
  BlockTypes,
  parseAndValidateDocumentOutput,
  ValidationResult
} from '@tfw.in/structura/sdk';

Development

Prerequisites

  • Node.js (version specified in package.json or higher)
  • Yarn or npm

Setup

  1. Clone the repository.
  2. Navigate to the sdk/typescript directory.
  3. Install dependencies:
    npm install
    or
    yarn install

Running Tests

To run the test suite:

npm test

or

yarn test

This will execute the tests defined in the tests/ directory using Jest.

Building

To build the TypeScript code (compiles to the dist directory):

npm run tsc # Assuming you add a script like "tsc": "tsc" to package.json
# or directly
npx tsc

(You might want to add a build script to your package.json like "build": "tsc")

Publishing to NPM (Maintainer Notes)

  1. Ensure package.json is correctly configured (name, version, main, types, files, repository, author, license, etc.).
  2. Build the project: npm run build (or npx tsc).
  3. Login to npm: npm login.
  4. Publish: npm publish.

Remember to increment the version in package.json before publishing updates.