@feathersjs/typebox
Advanced tools
Comparing version 5.0.0-pre.32 to 5.0.0-pre.33
@@ -6,2 +6,8 @@ # Change Log | ||
# [5.0.0-pre.33](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.32...v5.0.0-pre.33) (2022-11-08) | ||
### Features | ||
- **schema:** Add StringEnum to TypeBox module ([#2827](https://github.com/feathersjs/feathers/issues/2827)) ([65d3665](https://github.com/feathersjs/feathers/commit/65d36656f50a48f633fa3fcabaea10521d04bf1c)) | ||
# [5.0.0-pre.32](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.31...v5.0.0-pre.32) (2022-10-26) | ||
@@ -8,0 +14,0 @@ |
@@ -29,2 +29,8 @@ import { TObject, TInteger, TOptional, TSchema, TIntersect } from '@sinclair/typebox'; | ||
export declare const getDataValidator: (def: TObject | TDataSchemaMap, validator: Ajv) => DataValidatorMap; | ||
/** | ||
* A TypeBox utility that converts an array of provided strings into a string enum. | ||
* @param allowedValues array of strings for the enum | ||
* @returns TypeBox.Type | ||
*/ | ||
export declare function StringEnum<T extends string[]>(allowedValues: [...T]): import("@sinclair/typebox").TUnsafe<T[number]>; | ||
export declare function sortDefinition<T extends TObject>(schema: T): TObject<T["properties"] extends infer T_1 ? { [K in keyof T_1]: TOptional<TInteger>; } : never>; | ||
@@ -31,0 +37,0 @@ export declare const queryProperty: <T extends TSchema>(def: T) => TOptional<import("@sinclair/typebox").TUnion<[T, TObject<{ |
@@ -17,3 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.querySyntax = exports.queryProperties = exports.queryProperty = exports.sortDefinition = exports.getDataValidator = exports.getValidator = void 0; | ||
exports.querySyntax = exports.queryProperties = exports.queryProperty = exports.sortDefinition = exports.StringEnum = exports.getDataValidator = exports.getValidator = void 0; | ||
const typebox_1 = require("@sinclair/typebox"); | ||
@@ -48,2 +48,11 @@ const schema_1 = require("@feathersjs/schema"); | ||
}; | ||
/** | ||
* A TypeBox utility that converts an array of provided strings into a string enum. | ||
* @param allowedValues array of strings for the enum | ||
* @returns TypeBox.Type | ||
*/ | ||
function StringEnum(allowedValues) { | ||
return typebox_1.Type.Unsafe({ type: 'string', enum: allowedValues }); | ||
} | ||
exports.StringEnum = StringEnum; | ||
function sortDefinition(schema) { | ||
@@ -50,0 +59,0 @@ const properties = Object.keys(schema.properties).reduce((res, key) => { |
{ | ||
"name": "@feathersjs/typebox", | ||
"description": "TypeBox integration for @feathersjs/schema", | ||
"version": "5.0.0-pre.32", | ||
"version": "5.0.0-pre.33", | ||
"homepage": "https://feathersjs.com", | ||
@@ -57,13 +57,13 @@ "main": "lib/", | ||
"dependencies": { | ||
"@feathersjs/schema": "^5.0.0-pre.32", | ||
"@sinclair/typebox": "^0.24.44" | ||
"@feathersjs/schema": "^5.0.0-pre.33", | ||
"@sinclair/typebox": "^0.25.2" | ||
}, | ||
"devDependencies": { | ||
"@types/mocha": "^10.0.0", | ||
"@types/node": "^18.8.2", | ||
"mocha": "^10.0.0", | ||
"@types/node": "^18.11.9", | ||
"mocha": "^10.1.0", | ||
"shx": "^0.3.4", | ||
"typescript": "^4.8.4" | ||
}, | ||
"gitHead": "b405e205fc6d9fbd42b42c7a3f30ea4bf33d121d" | ||
"gitHead": "89f516bcb1457e23a02c6212e9cd8bacc4d267d4" | ||
} |
@@ -41,2 +41,11 @@ import { Type, TObject, TInteger, TOptional, TSchema, TIntersect } from '@sinclair/typebox' | ||
/** | ||
* A TypeBox utility that converts an array of provided strings into a string enum. | ||
* @param allowedValues array of strings for the enum | ||
* @returns TypeBox.Type | ||
*/ | ||
export function StringEnum<T extends string[]>(allowedValues: [...T]) { | ||
return Type.Unsafe<T[number]>({ type: 'string', enum: allowedValues }) | ||
} | ||
export function sortDefinition<T extends TObject>(schema: T) { | ||
@@ -43,0 +52,0 @@ const properties = Object.keys(schema.properties).reduce((res, key) => { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37228
522
+ Added@sinclair/typebox@0.25.24(transitive)
- Removed@sinclair/typebox@0.24.51(transitive)
Updated@sinclair/typebox@^0.25.2