std-json-api
Advanced tools
+1
-1
| { | ||
| "name": "std-json-api", | ||
| "version": "1.5.0", | ||
| "version": "1.6.0", | ||
| "description": "JSON-API standard utilities for NestJS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+1
-0
@@ -80,2 +80,3 @@ /** | ||
| cursor: string; | ||
| field: string; | ||
| limit: number; | ||
@@ -82,0 +83,0 @@ }; |
+1
-1
@@ -140,3 +140,3 @@ "use strict"; | ||
| // If no valid limit, return just cursor (though technically incomplete) | ||
| return { cursor, limit: 10 }; // Default limit | ||
| return { cursor, limit: 10 }; | ||
| } | ||
@@ -143,0 +143,0 @@ // Check for offset-based pagination |
+4
-68
| # std-json-api | ||
| Functional standard `JSON:API` serializers, schemas, and utilities for building | ||
| `JSON:API` compliant applications. | ||
| A comprehensive TypeScript library for building | ||
| [JSON:API v1.1](https://jsonapi.org/format/) compliant applications. | ||
| ## Types & Schemas | ||
| ### TODO | ||
| All types are exported from `std-api`. Each type has a `zod` schema that can be | ||
| used to validate the data structure. | ||
| ```typescript | ||
| import type { MetaObject } from "std-json-api/std-api"; | ||
| import type { metaObject } from "std-json-api/schemas/meta-object"; | ||
| // validate a meta object example | ||
| metaObject.parse({}); | ||
| ``` | ||
| ## ResourceDescriptor | ||
| A utility to describe a `JSON:API` resource with its attributes and | ||
| relationships. | ||
| ```typescript | ||
| import Describe from "std-json-api/descriptor"; | ||
| const desc = Describe("resource-id") | ||
| .addAttr("name", "string") | ||
| .addReleationship("related-resource", "related-type", "related-id") | ||
| .build(); | ||
| ``` | ||
| ## Functional Builder API | ||
| Provides a functional API for building `JSON:API` documents. | ||
| ```typescript | ||
| import {SingleDocument, Attributes, Meta, Resource, Id, Type} from "std-json-api/builder-fn"; | ||
| const doc = SingleDocument( | ||
| Meta({}), | ||
| Data( | ||
| Resource( | ||
| Id('...'), | ||
| Type('...'), | ||
| Attributes({ | ||
| ... | ||
| }) | ||
| ) | ||
| ) | ||
| ); | ||
| ``` | ||
| ## Builder API | ||
| Provides an API for building `JSON:API` documents. | ||
| ```typescript | ||
| import JsonApiBuilder from "std-json-api/builder"; | ||
| const doc = JsonApiBuilder | ||
| .singleDocument() | ||
| .meta({}) | ||
| .data( | ||
| JsonApiBuilder.resource() | ||
| .id('...') | ||
| .type('...') | ||
| .attributes({ | ||
| ... | ||
| }) | ||
| ) | ||
| ``` | ||
| - [ ] Add pagination builders by strategy (offset, cursor). |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
2168
0.05%1
-50%66328
-1.99%8
-89.04%