Registry / serialization / jsonapi-typescript

jsonapi-typescript

JSON →
library0.1.3jsnpmunverified

This package provides TypeScript type definitions for JSON:API documents, enabling compile-time validation of JSON:API structures within TypeScript projects. The current stable version is 0.1.3, released in April 2019. Given the lack of updates since then, its release cadence is effectively inactive, and it should be considered abandoned. Its primary differentiator is its sole focus on providing type-checking for JSON:API, without including any runtime parsing or serialization logic. This makes it a lightweight option for projects that already handle data fetching and serialization and only require type-safety enforcement against the JSON:API specification.

npm install jsonapi-typescript
INSTALL
IMPORT
SIG · JSONAPI-TYPESCRIPT
J
jsonapi-typescript
serializationjavascriptv0.1.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

JSONAPI
import * as JSONAPI from 'jsonapi-typescript';
const JSONAPI = require('jsonapi-typescript');
Primarily designed for ESM and TypeScript; CommonJS `require` won't provide type-checking.
Document
import { Document } from 'jsonapi-typescript';
import JSONAPI from 'jsonapi-typescript';
Specific types like `Document` are named exports. The package does not have a default export.
ResourceObject
import { ResourceObject } from 'jsonapi-typescript';
Commonly used for defining the structure of individual resources within a JSON:API document.

Demonstrates importing the type definitions and validating a basic JSON:API document structure at compile-time.

import * as JSONAPI from 'jsonapi-typescript'; // ✅ This should be OK (a valid single-resource JSON:API document) let validDoc: JSONAPI.Document = { data: { type: 'articles', id: '1', attributes: { title: 'Hello World' }, relationships: { author: { data: { type: 'people', id: '9' } } } } }; // ⛔️ This should NOT be OK (missing 'data' or 'errors' top-level keys, 'result' is invalid) // let invalidDoc1: JSONAPI.Document = { // result: "Success!" // }; // ⛔️ This should NOT be OK (empty Array is not a valid JSON:API document root) // let invalidDoc2: JSONAPI.Document = []; console.log('Valid JSON:API document example:', JSON.stringify(validDoc, null, 2));
Debug
Known issues
breakingThe package appears to be abandoned, with no updates since April 2019. It may not be compatible with newer TypeScript versions (beyond TS 2.3 mentioned) or the latest JSON:API specification (v1.1 published July 2020).
fix
Consider alternatives like `ts-japi` or `ts-json-api` for actively maintained and up-to-date JSON:API type solutions.
affects: <=0.1.3
gotchaThis package only provides type definitions; it does not include any runtime parsing, serialization, or client functionality. It's solely for compile-time validation.
fix
Pair this with a separate JSON:API client or serialization library if runtime operations are needed. Or use a library that combines types with runtime logic.
affects: *
gotchaThe type definitions might not fully encompass all optional or advanced features of the JSON:API specification (e.g., custom extensions, profiles) as the project predates later spec revisions.
fix
Manually extend or augment types if specific advanced JSON:API features not covered by this package are required.
affects: <=0.1.3
Errors
Common errors & fixes
Type '{ result: string; }' is not assignable to type 'Document'. Object literal may only specify known properties, and 'result' does not exist in type 'Document'.
Attempting to assign an object that does not conform to the JSON:API Document structure (e.g., using unknown top-level keys).
fix
Ensure the top-level document contains 'data', 'errors', or 'meta' members as per JSON:API specification.
Type 'string' is not assignable to type 'ResourceObject | ResourceObject[] | ResourceIdentifierObject | ResourceIdentifierObject[] | null | undefined'.
Assigning an incorrect type to a field expected to be a JSON:API primary data or relationship data (e.g., assigning a string where a ResourceObject is expected).
fix
Ensure that `data` and relationship `data` fields correctly specify `ResourceObject` or `ResourceIdentifierObject` types, or arrays thereof, as defined by JSON:API.
Property 'id' is missing in type '{ type: "articles"; }' but required in type 'ResourceObject<any, object>'.
Creating a `ResourceObject` without the mandatory `id` property.
fix
All `ResourceObject` and `ResourceIdentifierObject` types must include both `type` and `id` properties.
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
jsonapi-typescript — npm install jsonapi-typescript · libregistry