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

@feathersjs/typebox

Package Overview
Dependencies
Maintainers
3
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@feathersjs/typebox - npm Package Compare versions

Comparing version 5.0.4 to 5.0.5

6

CHANGELOG.md

@@ -6,2 +6,8 @@ # Change Log

## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28)
### Bug Fixes
- **typebox:** Revert to TypeBox 0.25 ([#3183](https://github.com/feathersjs/feathers/issues/3183)) ([cacedf5](https://github.com/feathersjs/feathers/commit/cacedf59e3d2df836777f0cd06ab1b2484ed87c5))
## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12)

@@ -8,0 +14,0 @@

70

lib/default-schemas.d.ts

@@ -33,9 +33,9 @@ import { Static } from '@sinclair/typebox';

client: import("@sinclair/typebox").TString<string>;
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TObject<{
host: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
port: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
user: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
password: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
database: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
}>]>;
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TPartial<import("@sinclair/typebox").TObject<{
host: import("@sinclair/typebox").TString<string>;
port: import("@sinclair/typebox").TNumber;
user: import("@sinclair/typebox").TString<string>;
password: import("@sinclair/typebox").TString<string>;
database: import("@sinclair/typebox").TString<string>;
}>>]>;
pool: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{

@@ -84,9 +84,9 @@ min: import("@sinclair/typebox").TNumber;

client: import("@sinclair/typebox").TString<string>;
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TObject<{
host: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
port: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
user: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
password: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
database: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
}>]>;
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TPartial<import("@sinclair/typebox").TObject<{
host: import("@sinclair/typebox").TString<string>;
port: import("@sinclair/typebox").TNumber;
user: import("@sinclair/typebox").TString<string>;
password: import("@sinclair/typebox").TString<string>;
database: import("@sinclair/typebox").TString<string>;
}>>]>;
pool: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{

@@ -99,9 +99,9 @@ min: import("@sinclair/typebox").TNumber;

client: import("@sinclair/typebox").TString<string>;
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TObject<{
host: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
port: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
user: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
password: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
database: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
}>]>;
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TPartial<import("@sinclair/typebox").TObject<{
host: import("@sinclair/typebox").TString<string>;
port: import("@sinclair/typebox").TNumber;
user: import("@sinclair/typebox").TString<string>;
password: import("@sinclair/typebox").TString<string>;
database: import("@sinclair/typebox").TString<string>;
}>>]>;
pool: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{

@@ -114,9 +114,9 @@ min: import("@sinclair/typebox").TNumber;

client: import("@sinclair/typebox").TString<string>;
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TObject<{
host: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
port: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
user: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
password: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
database: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
}>]>;
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TPartial<import("@sinclair/typebox").TObject<{
host: import("@sinclair/typebox").TString<string>;
port: import("@sinclair/typebox").TNumber;
user: import("@sinclair/typebox").TString<string>;
password: import("@sinclair/typebox").TString<string>;
database: import("@sinclair/typebox").TString<string>;
}>>]>;
pool: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{

@@ -129,9 +129,9 @@ min: import("@sinclair/typebox").TNumber;

client: import("@sinclair/typebox").TString<string>;
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TObject<{
host: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
port: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
user: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
password: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
database: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
}>]>;
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TPartial<import("@sinclair/typebox").TObject<{
host: import("@sinclair/typebox").TString<string>;
port: import("@sinclair/typebox").TNumber;
user: import("@sinclair/typebox").TString<string>;
password: import("@sinclair/typebox").TString<string>;
database: import("@sinclair/typebox").TString<string>;
}>>]>;
pool: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{

@@ -138,0 +138,0 @@ min: import("@sinclair/typebox").TNumber;

@@ -1,20 +0,5 @@

import { TObject, TInteger, TOptional, TSchema, TIntersect, ObjectOptions, ExtendedTypeBuilder, SchemaOptions, TNever, IntersectOptions } from '@sinclair/typebox';
import { TObject, TInteger, TOptional, TSchema, ObjectOptions } from '@sinclair/typebox';
import { Validator, DataValidatorMap, Ajv } from '@feathersjs/schema';
export * from '@sinclair/typebox';
export * from './default-schemas';
/**
* Feathers TypeBox customisations. Implements the 0.25.0 fallback for Intersect types.
* @see https://github.com/sinclairzx81/typebox/issues/373
*/
export declare class FeathersTypeBuilder extends ExtendedTypeBuilder {
/** `[Standard]` Creates a Intersect type */
Intersect(allOf: [], options?: SchemaOptions): TNever;
/** `[Standard]` Creates a Intersect type */
Intersect<T extends [TObject]>(allOf: [...T], options?: SchemaOptions): T[0];
Intersect<T extends TObject[]>(allOf: [...T], options?: IntersectOptions): TIntersect<T>;
}
/**
* Exports our own type builder
*/
export declare const Type: FeathersTypeBuilder;
export type TDataSchemaMap = {

@@ -32,3 +17,3 @@ create: TObject;

*/
export declare const getValidator: <T = any, R = T>(schema: TObject | TIntersect, validator: Ajv) => Validator<T, R>;
export declare const getValidator: <T = any, R = T>(schema: TObject, validator: Ajv) => Validator<T, R>;
/**

@@ -57,3 +42,3 @@ * Returns compiled validation functions to validate data for the `create`, `update` and `patch`

*/
export declare function sortDefinition<T extends TObject | TIntersect>(schema: T): TObject<T["properties"] extends infer T_1 ? { [K in keyof T_1]: TOptional<TInteger>; } : never>;
export declare function sortDefinition<T extends TObject>(schema: T): TObject<T["properties"] extends infer T_1 ? { [K in keyof T_1]: TOptional<TInteger>; } : never>;
/**

@@ -69,11 +54,11 @@ * Returns the standard Feathers query syntax for a property schema,

[key: string]: TSchema;
}>(def: T, extension?: X) => TOptional<import("@sinclair/typebox").TUnion<[T, import("@sinclair/typebox").TComposite<[TObject<import("@sinclair/typebox").Evaluate<import("@sinclair/typebox").Assert<{
$gt: T extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T>;
$gte: T extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T>;
$lt: T extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T>;
$lte: T extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T>;
$ne: T extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T>;
$in: TOptional<import("@sinclair/typebox").TArray<T>>;
$nin: TOptional<import("@sinclair/typebox").TArray<T>>;
}, import("@sinclair/typebox").TProperties>>>, TObject<import("@sinclair/typebox").Evaluate<import("@sinclair/typebox").Assert<{ [K in keyof X]: X[K] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : X[K] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : X[K] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<X[K]>; }, import("@sinclair/typebox").TProperties>>>]>]>>;
}>(def: T, extension?: X) => TOptional<import("@sinclair/typebox").TUnion<[T, import("@sinclair/typebox").TPartial<import("@sinclair/typebox").TIntersect<[TObject<{
$gt: T;
$gte: T;
$lt: T;
$lte: T;
$ne: T;
$in: import("@sinclair/typebox").TArray<T>;
$nin: import("@sinclair/typebox").TArray<T>;
}>, TObject<X>]>>]>>;
/**

@@ -86,13 +71,13 @@ * Creates a Feathers query syntax schema for the properties defined in `definition`.

*/
export declare const queryProperties: <T extends TObject<import("@sinclair/typebox").TProperties> | TIntersect<TSchema[]>, X extends T["properties"] extends infer T_1 ? { [K in keyof T_1]?: {
export declare const queryProperties: <T extends TObject<import("@sinclair/typebox").TProperties>, X extends T["properties"] extends infer T_1 ? { [K in keyof T_1]?: {
[key: string]: TSchema;
}; } : never>(definition: T, extensions?: X) => TOptional<TObject<T["properties"] extends infer T_2 ? { [K_1 in keyof T_2]: TOptional<import("@sinclair/typebox").TUnion<[T["properties"][K_1], import("@sinclair/typebox").TComposite<[TObject<import("@sinclair/typebox").Evaluate<import("@sinclair/typebox").Assert<{
$gt: T["properties"][K_1] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_1] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_1] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_1]>;
$gte: T["properties"][K_1] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_1] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_1] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_1]>;
$lt: T["properties"][K_1] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_1] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_1] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_1]>;
$lte: T["properties"][K_1] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_1] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_1] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_1]>;
$ne: T["properties"][K_1] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_1] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_1] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_1]>;
$in: TOptional<import("@sinclair/typebox").TArray<T["properties"][K_1]>>;
$nin: TOptional<import("@sinclair/typebox").TArray<T["properties"][K_1]>>;
}, import("@sinclair/typebox").TProperties>>>, TObject<import("@sinclair/typebox").Evaluate<import("@sinclair/typebox").Assert<X[K_1] extends infer T_3 extends import("@sinclair/typebox").TProperties ? { [K_2 in keyof T_3]: X[K_1][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : X[K_1][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : X[K_1][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<X[K_1][K_2]>; } : never, import("@sinclair/typebox").TProperties>>>]>]>>; } : never>>;
}; } : never>(definition: T, extensions?: X) => TOptional<TObject<T["properties"] extends infer T_2 ? { [K_1 in keyof T_2]: TOptional<import("@sinclair/typebox").TUnion<[T["properties"][K_1], import("@sinclair/typebox").TPartial<import("@sinclair/typebox").TIntersect<[TObject<{
$gt: T["properties"][K_1];
$gte: T["properties"][K_1];
$lt: T["properties"][K_1];
$lte: T["properties"][K_1];
$ne: T["properties"][K_1];
$in: import("@sinclair/typebox").TArray<T["properties"][K_1]>;
$nin: import("@sinclair/typebox").TArray<T["properties"][K_1]>;
}>, TObject<X[K_1]>]>>]>>; } : never>>;
/**

@@ -107,46 +92,46 @@ * Creates a TypeBox schema for the complete Feathers query syntax including `$limit`, $skip`, `$or`

*/
export declare const querySyntax: <T extends TObject<import("@sinclair/typebox").TProperties> | TIntersect<TSchema[]>, X extends T["properties"] extends infer T_1 ? { [K in keyof T_1]?: {
export declare const querySyntax: <T extends TObject<import("@sinclair/typebox").TProperties>, X extends T["properties"] extends infer T_1 ? { [K in keyof T_1]?: {
[key: string]: TSchema;
}; } : never>(type: T, extensions?: X, options?: ObjectOptions) => import("@sinclair/typebox").TComposite<[TObject<{
$limit: TOptional<import("@sinclair/typebox").TNumber>;
$skip: TOptional<import("@sinclair/typebox").TNumber>;
$sort: TOptional<TObject<T["properties"] extends infer T_2 ? { [K_1 in keyof T_2]: TOptional<TInteger>; } : never>>;
$select: TOptional<import("@sinclair/typebox").TUnsafe<(keyof T["properties"])[]>>;
$and: TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[TOptional<TObject<T["properties"] extends infer T_3 ? { [K_2 in keyof T_3]: TOptional<import("@sinclair/typebox").TUnion<[T["properties"][K_2], import("@sinclair/typebox").TComposite<[TObject<import("@sinclair/typebox").Evaluate<import("@sinclair/typebox").Assert<{
$gt: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$gte: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$lt: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$lte: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$ne: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$in: TOptional<import("@sinclair/typebox").TArray<T["properties"][K_2]>>;
$nin: TOptional<import("@sinclair/typebox").TArray<T["properties"][K_2]>>;
}, import("@sinclair/typebox").TProperties>>>, TObject<import("@sinclair/typebox").Evaluate<import("@sinclair/typebox").Assert<X[K_2] extends infer T_4 extends import("@sinclair/typebox").TProperties ? { [K_3 in keyof T_4]: X[K_2][K_3] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : X[K_2][K_3] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : X[K_2][K_3] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<X[K_2][K_3]>; } : never, import("@sinclair/typebox").TProperties>>>]>]>>; } : never>>, TObject<{
$or: import("@sinclair/typebox").TArray<TOptional<TObject<T["properties"] extends infer T_5 ? { [K_2 in keyof T_5]: TOptional<import("@sinclair/typebox").TUnion<[T["properties"][K_2], import("@sinclair/typebox").TComposite<[TObject<import("@sinclair/typebox").Evaluate<import("@sinclair/typebox").Assert<{
$gt: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$gte: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$lt: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$lte: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$ne: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$in: TOptional<import("@sinclair/typebox").TArray<T["properties"][K_2]>>;
$nin: TOptional<import("@sinclair/typebox").TArray<T["properties"][K_2]>>;
}, import("@sinclair/typebox").TProperties>>>, TObject<import("@sinclair/typebox").Evaluate<import("@sinclair/typebox").Assert<X[K_2] extends infer T_6 extends import("@sinclair/typebox").TProperties ? { [K_3 in keyof T_6]: X[K_2][K_3] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : X[K_2][K_3] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : X[K_2][K_3] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<X[K_2][K_3]>; } : never, import("@sinclair/typebox").TProperties>>>]>]>>; } : never>>>;
}>]>>>;
$or: TOptional<import("@sinclair/typebox").TArray<TOptional<TObject<T["properties"] extends infer T_7 ? { [K_2 in keyof T_7]: TOptional<import("@sinclair/typebox").TUnion<[T["properties"][K_2], import("@sinclair/typebox").TComposite<[TObject<import("@sinclair/typebox").Evaluate<import("@sinclair/typebox").Assert<{
$gt: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$gte: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$lt: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$lte: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$ne: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$in: TOptional<import("@sinclair/typebox").TArray<T["properties"][K_2]>>;
$nin: TOptional<import("@sinclair/typebox").TArray<T["properties"][K_2]>>;
}, import("@sinclair/typebox").TProperties>>>, TObject<import("@sinclair/typebox").Evaluate<import("@sinclair/typebox").Assert<X[K_2] extends infer T_8 extends import("@sinclair/typebox").TProperties ? { [K_3 in keyof T_8]: X[K_2][K_3] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : X[K_2][K_3] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : X[K_2][K_3] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<X[K_2][K_3]>; } : never, import("@sinclair/typebox").TProperties>>>]>]>>; } : never>>>>;
}>, TOptional<TObject<T["properties"] extends infer T_9 ? { [K_2 in keyof T_9]: TOptional<import("@sinclair/typebox").TUnion<[T["properties"][K_2], import("@sinclair/typebox").TComposite<[TObject<import("@sinclair/typebox").Evaluate<import("@sinclair/typebox").Assert<{
$gt: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$gte: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$lt: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$lte: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$ne: T["properties"][K_2] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : T["properties"][K_2] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : T["properties"][K_2] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<T["properties"][K_2]>;
$in: TOptional<import("@sinclair/typebox").TArray<T["properties"][K_2]>>;
$nin: TOptional<import("@sinclair/typebox").TArray<T["properties"][K_2]>>;
}, import("@sinclair/typebox").TProperties>>>, TObject<import("@sinclair/typebox").Evaluate<import("@sinclair/typebox").Assert<X[K_2] extends infer T_10 extends import("@sinclair/typebox").TProperties ? { [K_3 in keyof T_10]: X[K_2][K_3] extends import("@sinclair/typebox").TReadonlyOptional<infer U extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U> : X[K_2][K_3] extends import("@sinclair/typebox").TReadonly<infer U_1 extends TSchema> ? import("@sinclair/typebox").TReadonlyOptional<U_1> : X[K_2][K_3] extends TOptional<infer U_2 extends TSchema> ? TOptional<U_2> : TOptional<X[K_2][K_3]>; } : never, import("@sinclair/typebox").TProperties>>>]>]>>; } : never>>]>;
}; } : never>(type: T, extensions?: X, options?: ObjectOptions) => import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TPartial<TObject<{
$limit: import("@sinclair/typebox").TNumber;
$skip: import("@sinclair/typebox").TNumber;
$sort: TObject<T["properties"] extends infer T_2 ? { [K_1 in keyof T_2]: TOptional<TInteger>; } : never>;
$select: import("@sinclair/typebox").TUnsafe<(keyof T["properties"])[]>;
$and: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[TOptional<TObject<T["properties"] extends infer T_3 ? { [K_2 in keyof T_3]: TOptional<import("@sinclair/typebox").TUnion<[T["properties"][K_2], import("@sinclair/typebox").TPartial<import("@sinclair/typebox").TIntersect<[TObject<{
$gt: T["properties"][K_2];
$gte: T["properties"][K_2];
$lt: T["properties"][K_2];
$lte: T["properties"][K_2];
$ne: T["properties"][K_2];
$in: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
}>, TObject<X[K_2]>]>>]>>; } : never>>, TObject<{
$or: import("@sinclair/typebox").TArray<TOptional<TObject<T["properties"] extends infer T_4 ? { [K_2 in keyof T_4]: TOptional<import("@sinclair/typebox").TUnion<[T["properties"][K_2], import("@sinclair/typebox").TPartial<import("@sinclair/typebox").TIntersect<[TObject<{
$gt: T["properties"][K_2];
$gte: T["properties"][K_2];
$lt: T["properties"][K_2];
$lte: T["properties"][K_2];
$ne: T["properties"][K_2];
$in: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
}>, TObject<X[K_2]>]>>]>>; } : never>>>;
}>]>>;
$or: import("@sinclair/typebox").TArray<TOptional<TObject<T["properties"] extends infer T_5 ? { [K_2 in keyof T_5]: TOptional<import("@sinclair/typebox").TUnion<[T["properties"][K_2], import("@sinclair/typebox").TPartial<import("@sinclair/typebox").TIntersect<[TObject<{
$gt: T["properties"][K_2];
$gte: T["properties"][K_2];
$lt: T["properties"][K_2];
$lte: T["properties"][K_2];
$ne: T["properties"][K_2];
$in: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
}>, TObject<X[K_2]>]>>]>>; } : never>>>;
}>>, TOptional<TObject<T["properties"] extends infer T_6 ? { [K_2 in keyof T_6]: TOptional<import("@sinclair/typebox").TUnion<[T["properties"][K_2], import("@sinclair/typebox").TPartial<import("@sinclair/typebox").TIntersect<[TObject<{
$gt: T["properties"][K_2];
$gte: T["properties"][K_2];
$lt: T["properties"][K_2];
$lte: T["properties"][K_2];
$ne: T["properties"][K_2];
$in: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
}>, TObject<X[K_2]>]>>]>>; } : never>>]>;
export declare const ObjectIdSchema: () => import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, TObject<{}>]>;

@@ -17,3 +17,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ObjectIdSchema = exports.querySyntax = exports.queryProperties = exports.queryProperty = exports.sortDefinition = exports.StringEnum = exports.getDataValidator = exports.getValidator = exports.Type = exports.FeathersTypeBuilder = void 0;
exports.ObjectIdSchema = exports.querySyntax = exports.queryProperties = exports.queryProperty = exports.sortDefinition = exports.StringEnum = exports.getDataValidator = exports.getValidator = void 0;
const typebox_1 = require("@sinclair/typebox");

@@ -24,43 +24,2 @@ const schema_1 = require("@feathersjs/schema");

/**
* Feathers TypeBox customisations. Implements the 0.25.0 fallback for Intersect types.
* @see https://github.com/sinclairzx81/typebox/issues/373
*/
class FeathersTypeBuilder extends typebox_1.ExtendedTypeBuilder {
Intersect(allOf, options = {}) {
const [required, optional] = [new Set(), new Set()];
for (const object of allOf) {
for (const [key, property] of Object.entries(object.properties)) {
if (typebox_1.TypeGuard.TOptional(property) || typebox_1.TypeGuard.TReadonlyOptional(property))
optional.add(key);
}
}
for (const object of allOf) {
for (const key of Object.keys(object.properties)) {
if (!optional.has(key))
required.add(key);
}
}
const properties = {};
for (const object of allOf) {
for (const [key, schema] of Object.entries(object.properties)) {
properties[key] =
properties[key] === undefined
? schema
: { [typebox_1.Kind]: 'Union', anyOf: [properties[key], { ...schema }] };
}
}
if (required.size > 0) {
return { ...options, [typebox_1.Kind]: 'Object', type: 'object', properties, required: [...required] };
}
else {
return { ...options, [typebox_1.Kind]: 'Object', type: 'object', properties };
}
}
}
exports.FeathersTypeBuilder = FeathersTypeBuilder;
/**
* Exports our own type builder
*/
exports.Type = new FeathersTypeBuilder();
/**
* Returns a compiled validation function for a TypeBox object and AJV validator instance.

@@ -92,3 +51,3 @@ *

function StringEnum(allowedValues) {
return exports.Type.Unsafe({ type: 'string', enum: allowedValues });
return typebox_1.Type.Unsafe({ type: 'string', enum: allowedValues });
}

@@ -98,3 +57,3 @@ exports.StringEnum = StringEnum;

const keys = Object.keys(type.properties);
return exports.Type.Unsafe({
return typebox_1.Type.Unsafe({
type: 'array',

@@ -117,6 +76,6 @@ maxItems: keys.length,

const result = res;
result[key] = exports.Type.Optional(exports.Type.Integer({ minimum: -1, maximum: 1 }));
result[key] = typebox_1.Type.Optional(typebox_1.Type.Integer({ minimum: -1, maximum: 1 }));
return result;
}, {});
return exports.Type.Object(properties, { additionalProperties: false });
return typebox_1.Type.Object(properties, { additionalProperties: false });
}

@@ -132,6 +91,6 @@ exports.sortDefinition = sortDefinition;

*/
const queryProperty = (def, extension = {}) => exports.Type.Optional(exports.Type.Union([
const queryProperty = (def, extension = {}) => typebox_1.Type.Optional(typebox_1.Type.Union([
def,
exports.Type.Partial(exports.Type.Composite([
exports.Type.Object({
typebox_1.Type.Partial(typebox_1.Type.Intersect([
typebox_1.Type.Object({
$gt: def,

@@ -142,6 +101,6 @@ $gte: def,

$ne: def,
$in: exports.Type.Array(def),
$nin: exports.Type.Array(def)
$in: typebox_1.Type.Array(def),
$nin: typebox_1.Type.Array(def)
}),
exports.Type.Object(extension)
typebox_1.Type.Object(extension)
], { additionalProperties: false }))

@@ -164,3 +123,3 @@ ]));

}, {});
return exports.Type.Optional(exports.Type.Object(properties, { additionalProperties: false }));
return typebox_1.Type.Optional(typebox_1.Type.Object(properties, { additionalProperties: false }));
};

@@ -179,8 +138,8 @@ exports.queryProperties = queryProperties;

const propertySchema = (0, exports.queryProperties)(type, extensions);
const $or = exports.Type.Array(propertySchema);
const $and = exports.Type.Array(exports.Type.Union([propertySchema, exports.Type.Object({ $or })]));
return exports.Type.Composite([
exports.Type.Partial(exports.Type.Object({
$limit: exports.Type.Number({ minimum: 0 }),
$skip: exports.Type.Number({ minimum: 0 }),
const $or = typebox_1.Type.Array(propertySchema);
const $and = typebox_1.Type.Array(typebox_1.Type.Union([propertySchema, typebox_1.Type.Object({ $or })]));
return typebox_1.Type.Intersect([
typebox_1.Type.Partial(typebox_1.Type.Object({
$limit: typebox_1.Type.Number({ minimum: 0 }),
$skip: typebox_1.Type.Number({ minimum: 0 }),
$sort: sortDefinition(type),

@@ -195,4 +154,4 @@ $select: arrayOfKeys(type),

exports.querySyntax = querySyntax;
const ObjectIdSchema = () => exports.Type.Union([exports.Type.String({ objectid: true }), exports.Type.Object({}, { additionalProperties: false })]);
const ObjectIdSchema = () => typebox_1.Type.Union([typebox_1.Type.String({ objectid: true }), typebox_1.Type.Object({}, { additionalProperties: false })]);
exports.ObjectIdSchema = ObjectIdSchema;
//# sourceMappingURL=index.js.map
{
"name": "@feathersjs/typebox",
"description": "TypeBox integration for @feathersjs/schema",
"version": "5.0.4",
"version": "5.0.5",
"homepage": "https://feathersjs.com",

@@ -57,4 +57,4 @@ "main": "lib/",

"dependencies": {
"@feathersjs/schema": "^5.0.4",
"@sinclair/typebox": "^0.26.8"
"@feathersjs/schema": "^5.0.5",
"@sinclair/typebox": "^0.25.0"
},

@@ -68,3 +68,3 @@ "devDependencies": {

},
"gitHead": "376e89040991db500f1f327aa699322543315039"
"gitHead": "42bd5e40ec73b10939b9a008ae8e49c39a191009"
}

@@ -1,15 +0,2 @@

import {
TObject,
TInteger,
TOptional,
TSchema,
TIntersect,
ObjectOptions,
ExtendedTypeBuilder,
SchemaOptions,
TNever,
IntersectOptions,
TypeGuard,
Kind
} from '@sinclair/typebox'
import { Type, TObject, TInteger, TOptional, TSchema, ObjectOptions } from '@sinclair/typebox'
import { jsonSchema, Validator, DataValidatorMap, Ajv } from '@feathersjs/schema'

@@ -20,47 +7,2 @@

/**
* Feathers TypeBox customisations. Implements the 0.25.0 fallback for Intersect types.
* @see https://github.com/sinclairzx81/typebox/issues/373
*/
export class FeathersTypeBuilder extends ExtendedTypeBuilder {
/** `[Standard]` Creates a Intersect type */
public Intersect(allOf: [], options?: SchemaOptions): TNever
/** `[Standard]` Creates a Intersect type */
public Intersect<T extends [TObject]>(allOf: [...T], options?: SchemaOptions): T[0]
// /** `[Standard]` Creates a Intersect type */
public Intersect<T extends TObject[]>(allOf: [...T], options?: IntersectOptions): TIntersect<T>
public Intersect(allOf: TObject[], options: IntersectOptions = {}) {
const [required, optional] = [new Set<string>(), new Set<string>()]
for (const object of allOf) {
for (const [key, property] of Object.entries(object.properties)) {
if (TypeGuard.TOptional(property) || TypeGuard.TReadonlyOptional(property)) optional.add(key)
}
}
for (const object of allOf) {
for (const key of Object.keys(object.properties)) {
if (!optional.has(key)) required.add(key)
}
}
const properties = {} as Record<string, any>
for (const object of allOf) {
for (const [key, schema] of Object.entries(object.properties)) {
properties[key] =
properties[key] === undefined
? schema
: { [Kind]: 'Union', anyOf: [properties[key], { ...schema }] }
}
}
if (required.size > 0) {
return { ...options, [Kind]: 'Object', type: 'object', properties, required: [...required] } as any
} else {
return { ...options, [Kind]: 'Object', type: 'object', properties } as any
}
}
}
/**
* Exports our own type builder
*/
export const Type = new FeathersTypeBuilder()
export type TDataSchemaMap = {

@@ -79,3 +21,3 @@ create: TObject

*/
export const getValidator = <T = any, R = T>(schema: TObject | TIntersect, validator: Ajv): Validator<T, R> =>
export const getValidator = <T = any, R = T>(schema: TObject, validator: Ajv): Validator<T, R> =>
jsonSchema.getValidator(schema as any, validator)

@@ -105,3 +47,3 @@

const arrayOfKeys = <T extends TObject | TIntersect>(type: T) => {
const arrayOfKeys = <T extends TObject>(type: T) => {
const keys = Object.keys(type.properties)

@@ -124,3 +66,3 @@ return Type.Unsafe<(keyof T['properties'])[]>({

*/
export function sortDefinition<T extends TObject | TIntersect>(schema: T) {
export function sortDefinition<T extends TObject>(schema: T) {
const properties = Object.keys(schema.properties).reduce((res, key) => {

@@ -153,3 +95,3 @@ const result = res as any

Type.Partial(
Type.Composite(
Type.Intersect(
[

@@ -185,3 +127,3 @@ Type.Object({

export const queryProperties = <
T extends TObject | TIntersect,
T extends TObject,
X extends { [K in keyof T['properties']]?: { [key: string]: TSchema } }

@@ -214,3 +156,3 @@ >(

export const querySyntax = <
T extends TObject | TIntersect,
T extends TObject,
X extends { [K in keyof T['properties']]?: { [key: string]: TSchema } }

@@ -226,3 +168,3 @@ >(

return Type.Composite(
return Type.Intersect(
[

@@ -229,0 +171,0 @@ Type.Partial(

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