@feathersjs/typebox 5.0.5 → 5.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/lib/index.d.ts +18 -18
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @feathersjs/typebox
|
|
9
|
+
|
|
6
10
|
## [5.0.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28)
|
|
7
11
|
|
|
8
12
|
### Bug Fixes
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TObject, TInteger, TOptional, TSchema, ObjectOptions } from '@sinclair/typebox';
|
|
1
|
+
import { TObject, TInteger, TOptional, TSchema, ObjectOptions, TIntersect } from '@sinclair/typebox';
|
|
2
2
|
import { Validator, DataValidatorMap, Ajv } from '@feathersjs/schema';
|
|
3
3
|
export * from '@sinclair/typebox';
|
|
4
4
|
export * from './default-schemas';
|
|
@@ -14,7 +14,7 @@ export type TDataSchemaMap = {
|
|
|
14
14
|
* @param validator The AJV validation instance
|
|
15
15
|
* @returns A compiled validation function
|
|
16
16
|
*/
|
|
17
|
-
export declare const getValidator: <T = any, R = T>(schema: TObject, validator: Ajv) => Validator<T, R>;
|
|
17
|
+
export declare const getValidator: <T = any, R = T>(schema: TObject | TIntersect, validator: Ajv) => Validator<T, R>;
|
|
18
18
|
/**
|
|
19
19
|
* Returns compiled validation functions to validate data for the `create`, `update` and `patch`
|
|
20
20
|
* service methods. If not passed explicitly, the `update` validator will be the same as the `create`
|
|
@@ -38,7 +38,7 @@ export declare function StringEnum<T extends string[]>(allowedValues: [...T]): i
|
|
|
38
38
|
* @param schema The TypeBox object schema
|
|
39
39
|
* @returns The `$sort` syntax schema
|
|
40
40
|
*/
|
|
41
|
-
export declare function sortDefinition<T extends TObject>(schema: T): TObject<
|
|
41
|
+
export declare function sortDefinition<T extends TObject>(schema: T): TObject<{ [K in keyof T["properties"]]: TOptional<TInteger>; }>;
|
|
42
42
|
/**
|
|
43
43
|
* Returns the standard Feathers query syntax for a property schema,
|
|
44
44
|
* including operators like `$gt`, `$lt` etc. for a single property
|
|
@@ -49,7 +49,7 @@ export declare function sortDefinition<T extends TObject>(schema: T): TObject<T[
|
|
|
49
49
|
*/
|
|
50
50
|
export declare const queryProperty: <T extends TSchema, X extends {
|
|
51
51
|
[key: string]: TSchema;
|
|
52
|
-
}>(def: T, extension?: X) => TOptional<import("@sinclair/typebox").TUnion<[T, import("@sinclair/typebox").TPartial<
|
|
52
|
+
}>(def: T, extension?: X) => TOptional<import("@sinclair/typebox").TUnion<[T, import("@sinclair/typebox").TPartial<TIntersect<[TObject<{
|
|
53
53
|
$gt: T;
|
|
54
54
|
$gte: T;
|
|
55
55
|
$lt: T;
|
|
@@ -65,9 +65,9 @@ export declare const queryProperty: <T extends TSchema, X extends {
|
|
|
65
65
|
* @param extensions Additional properties to add to a property query
|
|
66
66
|
* @returns The Feathers query syntax schema
|
|
67
67
|
*/
|
|
68
|
-
export declare const queryProperties: <T extends TObject<import("@sinclair/typebox").TProperties>, X extends
|
|
68
|
+
export declare const queryProperties: <T extends TObject<import("@sinclair/typebox").TProperties>, X extends { [K in keyof T["properties"]]?: {
|
|
69
69
|
[key: string]: TSchema;
|
|
70
|
-
}; }
|
|
70
|
+
}; }>(definition: T, extensions?: X) => TOptional<TObject<{ [K_1 in keyof T["properties"]]: TOptional<import("@sinclair/typebox").TUnion<[T["properties"][K_1], import("@sinclair/typebox").TPartial<TIntersect<[TObject<{
|
|
71
71
|
$gt: T["properties"][K_1];
|
|
72
72
|
$gte: T["properties"][K_1];
|
|
73
73
|
$lt: T["properties"][K_1];
|
|
@@ -75,7 +75,7 @@ export declare const queryProperties: <T extends TObject<import("@sinclair/typeb
|
|
|
75
75
|
$ne: T["properties"][K_1];
|
|
76
76
|
$in: import("@sinclair/typebox").TArray<T["properties"][K_1]>;
|
|
77
77
|
$nin: import("@sinclair/typebox").TArray<T["properties"][K_1]>;
|
|
78
|
-
}>, TObject<X[K_1]>]>>]>>; }
|
|
78
|
+
}>, TObject<X[K_1]>]>>]>>; }>>;
|
|
79
79
|
/**
|
|
80
80
|
* Creates a TypeBox schema for the complete Feathers query syntax including `$limit`, $skip`, `$or`
|
|
81
81
|
* and `$sort` and `$select` for the allowed properties.
|
|
@@ -85,14 +85,14 @@ export declare const queryProperties: <T extends TObject<import("@sinclair/typeb
|
|
|
85
85
|
* @param options Options for the TypeBox object schema
|
|
86
86
|
* @returns A TypeBox object representing the complete Feathers query syntax for the given properties
|
|
87
87
|
*/
|
|
88
|
-
export declare const querySyntax: <T extends TObject<import("@sinclair/typebox").TProperties>, X extends
|
|
88
|
+
export declare const querySyntax: <T extends TObject<import("@sinclair/typebox").TProperties>, X extends { [K in keyof T["properties"]]?: {
|
|
89
89
|
[key: string]: TSchema;
|
|
90
|
-
}; }
|
|
90
|
+
}; }>(type: T, extensions?: X, options?: ObjectOptions) => TIntersect<[import("@sinclair/typebox").TPartial<TObject<{
|
|
91
91
|
$limit: import("@sinclair/typebox").TNumber;
|
|
92
92
|
$skip: import("@sinclair/typebox").TNumber;
|
|
93
|
-
$sort: TObject<
|
|
93
|
+
$sort: TObject<{ [K_1 in keyof T["properties"]]: TOptional<TInteger>; }>;
|
|
94
94
|
$select: import("@sinclair/typebox").TUnsafe<(keyof T["properties"])[]>;
|
|
95
|
-
$and: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[TOptional<TObject<
|
|
95
|
+
$and: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[TOptional<TObject<{ [K_2 in keyof T["properties"]]: TOptional<import("@sinclair/typebox").TUnion<[T["properties"][K_2], import("@sinclair/typebox").TPartial<TIntersect<[TObject<{
|
|
96
96
|
$gt: T["properties"][K_2];
|
|
97
97
|
$gte: T["properties"][K_2];
|
|
98
98
|
$lt: T["properties"][K_2];
|
|
@@ -100,8 +100,8 @@ export declare const querySyntax: <T extends TObject<import("@sinclair/typebox")
|
|
|
100
100
|
$ne: T["properties"][K_2];
|
|
101
101
|
$in: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
102
102
|
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
103
|
-
}>, TObject<X[K_2]>]>>]>>; }
|
|
104
|
-
$or: import("@sinclair/typebox").TArray<TOptional<TObject<
|
|
103
|
+
}>, TObject<X[K_2]>]>>]>>; }>>, TObject<{
|
|
104
|
+
$or: import("@sinclair/typebox").TArray<TOptional<TObject<{ [K_2 in keyof T["properties"]]: TOptional<import("@sinclair/typebox").TUnion<[T["properties"][K_2], import("@sinclair/typebox").TPartial<TIntersect<[TObject<{
|
|
105
105
|
$gt: T["properties"][K_2];
|
|
106
106
|
$gte: T["properties"][K_2];
|
|
107
107
|
$lt: T["properties"][K_2];
|
|
@@ -109,9 +109,9 @@ export declare const querySyntax: <T extends TObject<import("@sinclair/typebox")
|
|
|
109
109
|
$ne: T["properties"][K_2];
|
|
110
110
|
$in: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
111
111
|
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
112
|
-
}>, TObject<X[K_2]>]>>]>>; }
|
|
112
|
+
}>, TObject<X[K_2]>]>>]>>; }>>>;
|
|
113
113
|
}>]>>;
|
|
114
|
-
$or: import("@sinclair/typebox").TArray<TOptional<TObject<
|
|
114
|
+
$or: import("@sinclair/typebox").TArray<TOptional<TObject<{ [K_2 in keyof T["properties"]]: TOptional<import("@sinclair/typebox").TUnion<[T["properties"][K_2], import("@sinclair/typebox").TPartial<TIntersect<[TObject<{
|
|
115
115
|
$gt: T["properties"][K_2];
|
|
116
116
|
$gte: T["properties"][K_2];
|
|
117
117
|
$lt: T["properties"][K_2];
|
|
@@ -119,8 +119,8 @@ export declare const querySyntax: <T extends TObject<import("@sinclair/typebox")
|
|
|
119
119
|
$ne: T["properties"][K_2];
|
|
120
120
|
$in: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
121
121
|
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
122
|
-
}>, TObject<X[K_2]>]>>]>>; }
|
|
123
|
-
}>>, TOptional<TObject<
|
|
122
|
+
}>, TObject<X[K_2]>]>>]>>; }>>>;
|
|
123
|
+
}>>, TOptional<TObject<{ [K_2 in keyof T["properties"]]: TOptional<import("@sinclair/typebox").TUnion<[T["properties"][K_2], import("@sinclair/typebox").TPartial<TIntersect<[TObject<{
|
|
124
124
|
$gt: T["properties"][K_2];
|
|
125
125
|
$gte: T["properties"][K_2];
|
|
126
126
|
$lt: T["properties"][K_2];
|
|
@@ -128,5 +128,5 @@ export declare const querySyntax: <T extends TObject<import("@sinclair/typebox")
|
|
|
128
128
|
$ne: T["properties"][K_2];
|
|
129
129
|
$in: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
130
130
|
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
131
|
-
}>, TObject<X[K_2]>]>>]>>; }
|
|
131
|
+
}>, TObject<X[K_2]>]>>]>>; }>>]>;
|
|
132
132
|
export declare const ObjectIdSchema: () => import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, TObject<{}>]>;
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";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Ac;KACf,EACD,OAAO,CACR,CAAA;AACH,CAAC,CAAA;AA/BY,QAAA,WAAW,eA+BvB;AAEM,MAAM,cAAc,GAAG,GAAG,EAAE,CACjC,cAAI,CAAC,KAAK,CAAC,CAAC,cAAI,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,cAAI,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;AADpF,QAAA,cAAc,kBACsE"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feathersjs/typebox",
|
|
3
3
|
"description": "TypeBox integration for @feathersjs/schema",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.6",
|
|
5
5
|
"homepage": "https://feathersjs.com",
|
|
6
6
|
"main": "lib/",
|
|
7
7
|
"types": "lib/",
|
|
@@ -54,15 +54,15 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@feathersjs/schema": "^5.0.
|
|
57
|
+
"@feathersjs/schema": "^5.0.6",
|
|
58
58
|
"@sinclair/typebox": "^0.25.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/mocha": "^10.0.1",
|
|
62
|
-
"@types/node": "^
|
|
62
|
+
"@types/node": "^20.3.1",
|
|
63
63
|
"mocha": "^10.2.0",
|
|
64
64
|
"shx": "^0.3.4",
|
|
65
|
-
"typescript": "^5.
|
|
65
|
+
"typescript": "^5.1.3"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "71ac655d260fbc9aa65cd5b9a6c088f0187ace4e"
|
|
68
68
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Type, TObject, TInteger, TOptional, TSchema, ObjectOptions } from '@sinclair/typebox'
|
|
1
|
+
import { Type, TObject, TInteger, TOptional, TSchema, ObjectOptions, TIntersect } from '@sinclair/typebox'
|
|
2
2
|
import { jsonSchema, Validator, DataValidatorMap, Ajv } from '@feathersjs/schema'
|
|
3
3
|
|
|
4
4
|
export * from '@sinclair/typebox'
|
|
@@ -17,7 +17,7 @@ export type TDataSchemaMap = {
|
|
|
17
17
|
* @param validator The AJV validation instance
|
|
18
18
|
* @returns A compiled validation function
|
|
19
19
|
*/
|
|
20
|
-
export const getValidator = <T = any, R = T>(schema: TObject, validator: Ajv): Validator<T, R> =>
|
|
20
|
+
export const getValidator = <T = any, R = T>(schema: TObject | TIntersect, validator: Ajv): Validator<T, R> =>
|
|
21
21
|
jsonSchema.getValidator(schema as any, validator)
|
|
22
22
|
|
|
23
23
|
/**
|