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.0-pre.30 to 5.0.0-pre.31

6

CHANGELOG.md

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

# [5.0.0-pre.31](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.30...v5.0.0-pre.31) (2022-10-12)
### Features
- **cli:** Improve generated schema definitions ([#2783](https://github.com/feathersjs/feathers/issues/2783)) ([474a9fd](https://github.com/feathersjs/feathers/commit/474a9fda2107e9bcf357746320a8e00cda8182b6))
# [5.0.0-pre.30](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.29...v5.0.0-pre.30) (2022-10-07)

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

import { TObject, TInteger, TOptional, TSchema, TIntersect } from '@sinclair/typebox';
import { Validator, DataValidatorMap, Ajv } from '@feathersjs/schema';
export * from '@sinclair/typebox';
export * from './default-schemas';
export declare type TDataSchemaMap = {
create: TObject;
update?: TObject;
patch?: TObject;
};
/**
* Returns a compiled validation function for a TypeBox object and AJV validator instance.
*
* @param schema The JSON schema definition
* @param validator The AJV validation instance
* @returns A compiled validation function
*/
export declare const getValidator: <T = any, R = T>(schema: TObject, validator: Ajv) => Validator<T, R>;
/**
* Returns compiled validation functions to validate data for the `create`, `update` and `patch`
* service methods. If not passed explicitly, the `update` validator will be the same as the `create`
* and `patch` will be the `create` validator with no required fields.
*
* @param def Either general TypeBox object definition or a mapping of `create`, `update` and `patch`
* to their respective type object
* @param validator The Ajv instance to use as the validator
* @returns A map of validator functions
*/
export declare const getDataValidator: (def: TObject | TDataSchemaMap, validator: Ajv) => DataValidatorMap;
export declare function sortDefinition<T extends TObject>(schema: T): TObject<T["properties"] extends infer T_1 ? { [K in keyof T_1]: TOptional<TInteger>; } : never>;

@@ -23,2 +48,9 @@ export declare const queryProperty: <T extends TSchema>(def: T) => TOptional<import("@sinclair/typebox").TUnion<[T, TObject<{

}>]>>; } : never>;
/**
* Creates a TypeBox schema for the complete Feathers query syntax including `$limit`, $skip`
* and `$sort` and `$select` for the allowed properties.
*
* @param type The properties to create the query syntax for
* @returns A TypeBox object representing the complete Feathers query syntax for the given properties
*/
export declare const querySyntax: <T extends TObject<import("@sinclair/typebox").TProperties> | TIntersect<TObject<import("@sinclair/typebox").TProperties>[]>>(type: T) => TIntersect<[TObject<{

@@ -25,0 +57,0 @@ $limit: TOptional<import("@sinclair/typebox").TNumber>;

31

lib/index.js

@@ -17,6 +17,28 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.querySyntax = exports.queryProperties = exports.queryProperty = exports.sortDefinition = void 0;
exports.querySyntax = exports.queryProperties = exports.queryProperty = exports.sortDefinition = exports.getDataValidator = exports.getValidator = void 0;
const typebox_1 = require("@sinclair/typebox");
const schema_1 = require("@feathersjs/schema");
__exportStar(require("@sinclair/typebox"), exports);
__exportStar(require("./default-schemas"), exports);
/**
* Returns a compiled validation function for a TypeBox object and AJV validator instance.
*
* @param schema The JSON schema definition
* @param validator The AJV validation instance
* @returns A compiled validation function
*/
const getValidator = (schema, validator) => schema_1.jsonSchema.getValidator(schema, validator);
exports.getValidator = getValidator;
/**
* Returns compiled validation functions to validate data for the `create`, `update` and `patch`
* service methods. If not passed explicitly, the `update` validator will be the same as the `create`
* and `patch` will be the `create` validator with no required fields.
*
* @param def Either general TypeBox object definition or a mapping of `create`, `update` and `patch`
* to their respective type object
* @param validator The Ajv instance to use as the validator
* @returns A map of validator functions
*/
const getDataValidator = (def, validator) => schema_1.jsonSchema.getDataValidator(def, validator);
exports.getDataValidator = getDataValidator;
const arrayOfKeys = (type) => {

@@ -67,2 +89,9 @@ const keys = Object.keys(type.properties);

exports.queryProperties = queryProperties;
/**
* Creates a TypeBox schema for the complete Feathers query syntax including `$limit`, $skip`
* and `$sort` and `$select` for the allowed properties.
*
* @param type The properties to create the query syntax for
* @returns A TypeBox object representing the complete Feathers query syntax for the given properties
*/
const querySyntax = (type) => {

@@ -69,0 +98,0 @@ return typebox_1.Type.Intersect([

6

package.json
{
"name": "@feathersjs/typebox",
"description": "TypeBox integration for @feathersjs/schema",
"version": "5.0.0-pre.30",
"version": "5.0.0-pre.31",
"homepage": "https://feathersjs.com",

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

"dependencies": {
"@feathersjs/schema": "^5.0.0-pre.31",
"@sinclair/typebox": "^0.24.44"
},
"devDependencies": {
"@feathersjs/schema": "^5.0.0-pre.30",
"@types/mocha": "^10.0.0",

@@ -68,3 +68,3 @@ "@types/node": "^18.8.2",

},
"gitHead": "b535c91197f4b997520e0a0e608793eeba791931"
"gitHead": "4500dbeb8cea566678cf88b3313a88efd93a2ed9"
}
import { Type, TObject, TInteger, TOptional, TSchema, TIntersect } from '@sinclair/typebox'
import { jsonSchema, Validator, DataValidatorMap, Ajv } from '@feathersjs/schema'

@@ -6,2 +7,31 @@ export * from '@sinclair/typebox'

export type TDataSchemaMap = {
create: TObject
update?: TObject
patch?: TObject
}
/**
* Returns a compiled validation function for a TypeBox object and AJV validator instance.
*
* @param schema The JSON schema definition
* @param validator The AJV validation instance
* @returns A compiled validation function
*/
export const getValidator = <T = any, R = T>(schema: TObject, validator: Ajv): Validator<T, R> =>
jsonSchema.getValidator(schema as any, validator)
/**
* Returns compiled validation functions to validate data for the `create`, `update` and `patch`
* service methods. If not passed explicitly, the `update` validator will be the same as the `create`
* and `patch` will be the `create` validator with no required fields.
*
* @param def Either general TypeBox object definition or a mapping of `create`, `update` and `patch`
* to their respective type object
* @param validator The Ajv instance to use as the validator
* @returns A map of validator functions
*/
export const getDataValidator = (def: TObject | TDataSchemaMap, validator: Ajv): DataValidatorMap =>
jsonSchema.getDataValidator(def as any, validator)
const arrayOfKeys = <T extends TObject>(type: T) => {

@@ -63,2 +93,9 @@ const keys = Object.keys(type.properties)

/**
* Creates a TypeBox schema for the complete Feathers query syntax including `$limit`, $skip`
* and `$sort` and `$select` for the allowed properties.
*
* @param type The properties to create the query syntax for
* @returns A TypeBox object representing the complete Feathers query syntax for the given properties
*/
export const querySyntax = <T extends TObject | TIntersect>(type: T) => {

@@ -65,0 +102,0 @@ return Type.Intersect([

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