🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@clipboard-health/json-api-nestjs

Package Overview
Dependencies
Maintainers
0
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version

to
0.2.0

src/lib/query/createSort.d.ts

2

package.json
{
"name": "@clipboard-health/json-api-nestjs",
"description": "Utilities for adhering to the JSON:API specification with NestJS.",
"version": "0.1.0",
"version": "0.2.0",
"dependencies": {

@@ -6,0 +6,0 @@ "tslib": "2.7.0",

export * from "./lib/query/createCursorPagination";
export * from "./lib/query/createFields";
export * from "./lib/query/createFilter";
export * from "./lib/query/createSort";
export * from "./lib/schemas";
export * from "./lib/types";

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

tslib_1.__exportStar(require("./lib/query/createFilter"), exports);
tslib_1.__exportStar(require("./lib/query/createSort"), exports);
tslib_1.__exportStar(require("./lib/schemas"), exports);
tslib_1.__exportStar(require("./lib/types"), exports);
//# sourceMappingURL=index.js.map
import { z } from "zod";
/**
* Creates a Zod schema for JSON:API cursor pagination.
*
* @includeExample ./packages/json-api-nestjs/examples/query.ts
*
* @see [Usage example](../../../examples/query.ts)
* @see {@link https://jsonapi.org/format/#fetching-pagination JSON:API pagination}
* @see {@link https://jsonapi.org/examples/#pagination JSON:API pagination examples}
*/
export declare function createCursorPagination(parameters?: Readonly<{

@@ -3,0 +12,0 @@ maximumSize?: number;

@@ -6,2 +6,11 @@ "use strict";

const schemas_1 = require("../schemas");
/**
* Creates a Zod schema for JSON:API cursor pagination.
*
* @includeExample ./packages/json-api-nestjs/examples/query.ts
*
* @see [Usage example](../../../examples/query.ts)
* @see {@link https://jsonapi.org/format/#fetching-pagination JSON:API pagination}
* @see {@link https://jsonapi.org/examples/#pagination JSON:API pagination examples}
*/
function createCursorPagination(parameters) {

@@ -8,0 +17,0 @@ const { maximumSize = 200, defaultSize = 20 } = parameters ?? {};

import { z } from "zod";
import { type ApiType } from "../types";
type Field = string;
import { type ApiType, type Field } from "../types";
export type FieldsMap = Record<ApiType, readonly [Field, ...Field[]]>;

@@ -8,5 +7,12 @@ export type FieldsSchema<MapT extends FieldsMap> = {

};
/**
* Creates a Zod schema for JSON:API sparse fieldsets.
*
* @includeExample ./packages/json-api-nestjs/examples/query.ts
*
* @see [Usage example](../../../examples/query.ts)
* @see {@link https://jsonapi.org/format/#fetching-sparse-fieldsets JSON:API sparse fieldsets}
*/
export declare function createFields<const MapT extends FieldsMap>(parameters: Readonly<MapT>): {
fields: z.ZodOptional<z.ZodObject<FieldsSchema<MapT>, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<FieldsSchema<MapT>>, any> extends infer T ? { [k in keyof T]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<FieldsSchema<MapT>>, any>[k]; } : never, z.baseObjectInputType<FieldsSchema<MapT>> extends infer T_1 ? { [k_1 in keyof T_1]: z.baseObjectInputType<FieldsSchema<MapT>>[k_1]; } : never>>;
};
export {};

@@ -6,2 +6,10 @@ "use strict";

const splitString_1 = require("../internal/splitString");
/**
* Creates a Zod schema for JSON:API sparse fieldsets.
*
* @includeExample ./packages/json-api-nestjs/examples/query.ts
*
* @see [Usage example](../../../examples/query.ts)
* @see {@link https://jsonapi.org/format/#fetching-sparse-fieldsets JSON:API sparse fieldsets}
*/
function createFields(parameters) {

@@ -8,0 +16,0 @@ const fieldSchemas = Object.fromEntries(Object.entries(parameters).map(([apiType, fields]) => [

import { z } from "zod";
import { type ApiType } from "../types";
export type Filter = "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "not";
export type Filter = "eq" | "ne" | "gt" | "gte" | "lt" | "lte";
export type FilterMap = Record<ApiType, {

@@ -8,3 +8,3 @@ filters: readonly [Filter, ...Filter[]];

}>;
export type FilterObject<MapT extends FilterMap> = {
export type FilterSchema<MapT extends FilterMap> = {
[K in keyof MapT]: z.ZodOptional<z.ZodEffects<z.ZodOptional<z.ZodObject<{

@@ -14,4 +14,13 @@ [F in MapT[K]["filters"][number]]: z.ZodOptional<z.ZodEffects<z.ZodOptional<z.ZodArray<MapT[K]["schema"]>>>>;

};
/**
* Creates a Zod schema for JSON:API filters.
*
* @includeExample ./packages/json-api-nestjs/examples/query.ts
*
* @see [Usage example](../../../examples/query.ts)
* @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}
*/
export declare function createFilter<const MapT extends FilterMap>(parameters: Readonly<MapT>): {
filter: z.ZodOptional<z.ZodObject<FilterObject<MapT>, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<FilterObject<MapT>>, any> extends infer T ? { [k in keyof T]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<FilterObject<MapT>>, any>[k]; } : never, z.baseObjectInputType<FilterObject<MapT>> extends infer T_1 ? { [k_1 in keyof T_1]: z.baseObjectInputType<FilterObject<MapT>>[k_1]; } : never>>;
filter: z.ZodOptional<z.ZodObject<FilterSchema<MapT>, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<FilterSchema<MapT>>, any> extends infer T ? { [k in keyof T]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<FilterSchema<MapT>>, any>[k]; } : never, z.baseObjectInputType<FilterSchema<MapT>> extends infer T_1 ? { [k_1 in keyof T_1]: z.baseObjectInputType<FilterSchema<MapT>>[k_1]; } : never>>;
};

@@ -7,2 +7,11 @@ "use strict";

const splitString_1 = require("../internal/splitString");
/**
* Creates a Zod schema for JSON:API filters.
*
* @includeExample ./packages/json-api-nestjs/examples/query.ts
*
* @see [Usage example](../../../examples/query.ts)
* @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}
*/
function createFilter(parameters) {

@@ -9,0 +18,0 @@ return {

import { z } from "zod";
/**
* A non-empty string Zod schema.
*/
export declare const nonEmptyString: z.ZodString;
/**
* A Zod schema for use with boolean query parameters since `z.coerce.boolean()` treats any truthy
* value as `true`.
*/
export declare const booleanString: z.ZodEffects<z.ZodEnum<["true", "false"]>, boolean, "true" | "false">;

@@ -5,4 +5,11 @@ "use strict";

const zod_1 = require("zod");
/**
* A non-empty string Zod schema.
*/
exports.nonEmptyString = zod_1.z.string().min(1);
/**
* A Zod schema for use with boolean query parameters since `z.coerce.boolean()` treats any truthy
* value as `true`.
*/
exports.booleanString = zod_1.z.enum(["true", "false"]).transform((value) => value === "true");
//# sourceMappingURL=schemas.js.map
export type ApiType = string;
export type Field = string;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet