Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@amritk/helpers

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@amritk/helpers

Shared utilities for the mjst code generation ecosystem.

latest
Source
npmnpm
Version
0.10.0
Version published
Maintainers
1
Created
Source

@amritk/helpers

Shared schema-traversal and runtime helpers for the mjst code generation ecosystem.

status  version  license  JSON Schema  node  vibe coded

Overview

@amritk/helpers is the shared utility belt used by mjst's generators and by the runtime code those generators produce. Each helper is published as its own subpath export so consumers (and generated output) only pull in what they need — no barrel, no incidental dependencies.

Installation

npm install @amritk/helpers
# or
pnpm add @amritk/helpers
# or
yarn add @amritk/helpers
# or
bun add @amritk/helpers

Modules

Schema traversal

SubpathExportsPurpose
@amritk/helpers/extract-refsextractRefsCollect every $ref reachable from a schema.
@amritk/helpers/resolve-refresolveRefResolve a JSON pointer $ref against a root schema.
@amritk/helpers/build-dynamic-ref-mapbuildDynamicRefMapBuild a map of $dynamicAnchor → resolved location.
@amritk/helpers/resolve-dynamic-refsresolveDynamicRefsReplace $dynamicRef occurrences using the map above.
@amritk/helpers/upgrade-draft07-schemaupgradeDraft07Schema, isDraft07SchemaUpgrade a Draft-07 schema to 2020-12.
@amritk/helpers/ref-to-filenamerefToFilename, toKebabCaseConvert a $ref to a stable filename.
@amritk/helpers/ref-to-namerefToNameConvert a $ref to a TypeScript identifier (PascalCase).
@amritk/helpers/schema-guardsisSchemaObject, hasType, hasProperties, hasOneOf, hasAnyOf, hasAllOf, hasEnum, hasConst, hasPattern, hasFormat, hasDefault, hasExamples, hasRequired, hasItems, hasAdditionalProperties, hasMinLength, hasMaxLength, hasMinimum, hasMaximum, hasExclusiveMinimum, hasExclusiveMaximum, hasMultipleOf, hasMinItems, hasMaxItems, hasUniqueItems, hasMinProperties, hasMaxProperties, …Type-narrowing predicates for JSON Schema keywords.

Codegen utilities

SubpathExportsPurpose
@amritk/helpers/generate-type-definitiongenerateTypeDefinitionRender a TypeScript type from a schema node.
@amritk/helpers/parse-documentationparseDocumentation, ObjectDocumentationParse a markdown doc file into per-property descriptions.

Runtime helpers (also copied into generated output)

SubpathExportsPurpose
@amritk/helpers/is-objectisObjectNarrow unknownRecord<string, unknown>.
@amritk/helpers/safe-accessorsafeAccessorRead a key from an unknown value without throwing.
@amritk/helpers/validate-arrayvalidateArrayValidate array shape and items.
@amritk/helpers/validate-recordvalidateRecordValidate record shape and additional properties.

Usage

import { resolveRef } from '@amritk/helpers/resolve-ref'
import { isObjectSchema, hasProperties } from '@amritk/helpers/schema-guards'

const node = resolveRef('#/$defs/info', rootSchema)

if (isObjectSchema(node) && hasProperties(node)) {
  for (const [name, property] of Object.entries(node.properties)) {
    // ...
  }
}

Each helper has its own colocated test file (*.test.ts) — read those for canonical examples.

License

MIT

Keywords

json-schema

FAQs

Package last updated on 10 Jun 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts