Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@clipboard-health/json-api

Package Overview
Dependencies
Maintainers
0
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clipboard-health/json-api - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

2

package.json
{
"name": "@clipboard-health/json-api",
"description": "Utilities for adhering to the JSON:API specification.",
"version": "0.3.0",
"version": "0.4.0",
"bugs": "https://github.com/clipboardhealth/core-utils/issues",

@@ -6,0 +6,0 @@ "dependencies": {

@@ -36,9 +36,9 @@ # @clipboard-health/json-api

const query: ClientJsonApiQuery = {
fields: { dog: ["name", "age"] },
fields: { user: ["age", "name"] },
filter: {
age: { eq: ["2"] },
createdAt: { gt: [date1], lt: [date2] },
isGoodDog: { eq: ["true"] },
dateOfBirth: { gt: [date1], lt: [date2] },
isActive: { eq: ["true"] },
},
include: ["owner"],
include: ["article"],
page: {

@@ -53,3 +53,3 @@ size: "10",

new URLSearchParams(
`fields[dog]=name,age&filter[age]=2&filter[createdAt][gt]=${date1}&filter[createdAt][lt]=${date2}&filter[isGoodDog]=true&include=owner&page[size]=10&sort=-age`,
`fields[user]=age,name&filter[age]=2&filter[dateOfBirth][gt]=${date1}&filter[dateOfBirth][lt]=${date2}&filter[isActive]=true&include=article&page[size]=10&sort=-age`,
).toString(),

@@ -73,3 +73,3 @@ );

const searchParams = new URLSearchParams(
`fields[dog]=name,age&filter[age]=2&filter[createdAt][gt]=${date1}&filter[createdAt][lt]=${date2}&filter[isGoodDog]=true&include=owner&page[size]=10&sort=-age`,
`fields[user]=age,name&filter[age]=2&filter[dateOfBirth][gt]=${date1}&filter[dateOfBirth][lt]=${date2}&filter[isActive]=true&include=article&page[size]=10&sort=-age`,
);

@@ -80,9 +80,9 @@

deepEqual(query, {
fields: { dog: ["name", "age"] },
fields: { user: ["age", "name"] },
filter: {
age: { eq: ["2"] },
createdAt: { gt: [date1], lt: [date2] },
isGoodDog: { eq: ["true"] },
dateOfBirth: { gt: [date1], lt: [date2] },
isActive: { eq: ["true"] },
},
include: ["owner"],
include: ["article"],
page: {

@@ -89,0 +89,0 @@ size: "10",

@@ -5,4 +5,6 @@ import { type ClientJsonApiQuery } from "../types";

*
* @see [Example](https://github.com/ClipboardHealth/core-utils/blob/main/packages/json-api/examples/toSearchParams.ts)
* @includeExample ./packages/json-api/examples/toClientSearchParams.ts
*
* @see [Usage example](../../../examples/toClientSearchParams.ts)
*/
export declare function toClientSearchParams(query: ClientJsonApiQuery): URLSearchParams;

@@ -13,3 +13,5 @@ "use strict";

*
* @see [Example](https://github.com/ClipboardHealth/core-utils/blob/main/packages/json-api/examples/toSearchParams.ts)
* @includeExample ./packages/json-api/examples/toClientSearchParams.ts
*
* @see [Usage example](../../../examples/toClientSearchParams.ts)
*/

@@ -16,0 +18,0 @@ function toClientSearchParams(query) {

@@ -5,4 +5,6 @@ import { type ServerJsonApiQuery } from "../types";

*
* @see [Example](https://github.com/ClipboardHealth/core-utils/blob/main/packages/json-api/examples/toJsonApiQuery.ts)
* @includeExample packages/json-api/examples/toServerJsonApiQuery.ts
*
* @see [Usage example](../../../examples/toServerJsonApiQuery.ts)
*/
export declare function toServerJsonApiQuery(searchParams: URLSearchParams): ServerJsonApiQuery;

@@ -15,3 +15,5 @@ "use strict";

*
* @see [Example](https://github.com/ClipboardHealth/core-utils/blob/main/packages/json-api/examples/toJsonApiQuery.ts)
* @includeExample packages/json-api/examples/toServerJsonApiQuery.ts
*
* @see [Usage example](../../../examples/toServerJsonApiQuery.ts)
*/

@@ -18,0 +20,0 @@ function toServerJsonApiQuery(searchParams) {

@@ -9,7 +9,7 @@ /**

* - lte: Less than or equal to.
* - not: Not.
*/
type FilterType = "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "not";
type FilterType = "eq" | "ne" | "gt" | "gte" | "lt" | "lte";
type PageKey = "cursor" | "limit" | "number" | "offset" | "size";
interface JsonApiQueryTypes {
export { type URLSearchParams } from "node:url";
export interface JsonApiQueryTypes {
filterValue: unknown;

@@ -22,3 +22,3 @@ pageValue: unknown;

}
interface ServerTypes {
export interface ServerTypes {
filterValue: string[];

@@ -30,7 +30,7 @@ pageValue: string;

*/
interface JsonApiQuery<T extends JsonApiQueryTypes> {
export interface JsonApiQuery<T extends JsonApiQueryTypes> {
/**
* Fields to include in the response.
*
* @see {@link https://jsonapi.org/format/#fetching-sparse-fieldsets Sparse fieldsets}
* @see {@link https://jsonapi.org/format/#fetching-sparse-fieldsets JSON:API sparse fieldsets}
*/

@@ -41,4 +41,4 @@ fields?: Record<string, string[]>;

*
* @see {@link https://jsonapi.org/recommendations/#filtering Filtering}
* @see {@link https://discuss.jsonapi.org/t/share-propose-a-filtering-strategy/257 Filtering strategy}
* @see {@link https://jsonapi.org/recommendations/#filtering JSON:API filtering}
* @see {@link https://discuss.jsonapi.org/t/share-propose-a-filtering-strategy/257 JSON:API filtering strategy}
*/

@@ -51,3 +51,3 @@ filter?: Record<string, {

*
* @see {@link https://jsonapi.org/format/#fetching-includes Fetching includes}
* @see {@link https://jsonapi.org/format/#fetching-includes JSON:API fetching includes}
*/

@@ -58,4 +58,4 @@ include?: string[];

*
* @see {@link https://jsonapi.org/format/#fetching-pagination Pagination}
* @see {@link https://jsonapi.org/examples/#pagination Pagination examples}
* @see {@link https://jsonapi.org/format/#fetching-pagination JSON:API pagination}
* @see {@link https://jsonapi.org/examples/#pagination JSON:API pagination examples}
*/

@@ -68,3 +68,3 @@ page?: {

*
* @see {@link https://jsonapi.org/format/#fetching-sorting Sorting}
* @see {@link https://jsonapi.org/format/#fetching-sorting JSON:API sorting}
*/

@@ -75,2 +75,1 @@ sort?: string[];

export type ServerJsonApiQuery = JsonApiQuery<ServerTypes>;
export {};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc