@feathersjs/typebox 5.0.8 → 5.0.9
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 +5 -7
- package/lib/index.d.ts +9 -9
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +14 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,22 +3,20 @@
|
|
|
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.
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @feathersjs/typebox
|
|
6
|
+
## [5.0.9](https://github.com/feathersjs/feathers/compare/v5.0.8...v5.0.9) (2023-09-27)
|
|
9
7
|
|
|
8
|
+
### Bug Fixes
|
|
10
9
|
|
|
10
|
+
- **typebox:** allow TUnion<TObject[]> inside getValidator ([#3262](https://github.com/feathersjs/feathers/issues/3262)) ([cf9df96](https://github.com/feathersjs/feathers/commit/cf9df96c1011fcf13e9c6d652b06036bb0aac1c3))
|
|
11
11
|
|
|
12
|
+
## [5.0.8](https://github.com/feathersjs/feathers/compare/v5.0.7...v5.0.8) (2023-07-19)
|
|
12
13
|
|
|
14
|
+
**Note:** Version bump only for package @feathersjs/typebox
|
|
13
15
|
|
|
14
16
|
## [5.0.7](https://github.com/feathersjs/feathers/compare/v5.0.6...v5.0.7) (2023-07-14)
|
|
15
17
|
|
|
16
18
|
**Note:** Version bump only for package @feathersjs/typebox
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
20
|
## [5.0.6](https://github.com/feathersjs/feathers/compare/v5.0.5...v5.0.6) (2023-06-15)
|
|
23
21
|
|
|
24
22
|
**Note:** Version bump only for package @feathersjs/typebox
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TObject, TInteger, TOptional, TSchema, ObjectOptions, TIntersect } from '@sinclair/typebox';
|
|
1
|
+
import { TObject, TInteger, TOptional, TSchema, ObjectOptions, TIntersect, TUnion } 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 | TIntersect
|
|
17
|
+
export declare const getValidator: <T = any, R = T>(schema: TObject | TIntersect | TUnion<TObject[]>, 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`
|
|
@@ -49,7 +49,7 @@ export declare function sortDefinition<T extends TObject>(schema: T): TObject<{
|
|
|
49
49
|
*/
|
|
50
50
|
export declare const queryProperty: <T extends TSchema, X extends {
|
|
51
51
|
[key: string]: TSchema;
|
|
52
|
-
}>(def: T, extension?: X) => TOptional<
|
|
52
|
+
}>(def: T, extension?: X) => TOptional<TUnion<[T, import("@sinclair/typebox").TPartial<TIntersect<[TObject<{
|
|
53
53
|
$gt: T;
|
|
54
54
|
$gte: T;
|
|
55
55
|
$lt: T;
|
|
@@ -67,7 +67,7 @@ export declare const queryProperty: <T extends TSchema, X extends {
|
|
|
67
67
|
*/
|
|
68
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
|
-
}; }>(definition: T, extensions?: X) => TOptional<TObject<{ [K_1 in keyof T["properties"]]: TOptional<
|
|
70
|
+
}; }>(definition: T, extensions?: X) => TOptional<TObject<{ [K_1 in keyof T["properties"]]: TOptional<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];
|
|
@@ -92,7 +92,7 @@ export declare const querySyntax: <T extends TObject<import("@sinclair/typebox")
|
|
|
92
92
|
$skip: import("@sinclair/typebox").TNumber;
|
|
93
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<
|
|
95
|
+
$and: import("@sinclair/typebox").TArray<TUnion<[TOptional<TObject<{ [K_2 in keyof T["properties"]]: TOptional<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];
|
|
@@ -101,7 +101,7 @@ export declare const querySyntax: <T extends TObject<import("@sinclair/typebox")
|
|
|
101
101
|
$in: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
102
102
|
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
103
103
|
}>, TObject<X[K_2]>]>>]>>; }>>, TObject<{
|
|
104
|
-
$or: import("@sinclair/typebox").TArray<TOptional<TObject<{ [K_2 in keyof T["properties"]]: TOptional<
|
|
104
|
+
$or: import("@sinclair/typebox").TArray<TOptional<TObject<{ [K_2 in keyof T["properties"]]: TOptional<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];
|
|
@@ -111,7 +111,7 @@ export declare const querySyntax: <T extends TObject<import("@sinclair/typebox")
|
|
|
111
111
|
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
112
112
|
}>, TObject<X[K_2]>]>>]>>; }>>>;
|
|
113
113
|
}>]>>;
|
|
114
|
-
$or: import("@sinclair/typebox").TArray<TOptional<TObject<{ [K_2 in keyof T["properties"]]: TOptional<
|
|
114
|
+
$or: import("@sinclair/typebox").TArray<TOptional<TObject<{ [K_2 in keyof T["properties"]]: TOptional<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];
|
|
@@ -120,7 +120,7 @@ export declare const querySyntax: <T extends TObject<import("@sinclair/typebox")
|
|
|
120
120
|
$in: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
121
121
|
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
122
122
|
}>, TObject<X[K_2]>]>>]>>; }>>>;
|
|
123
|
-
}>>, TOptional<TObject<{ [K_2 in keyof T["properties"]]: TOptional<
|
|
123
|
+
}>>, TOptional<TObject<{ [K_2 in keyof T["properties"]]: TOptional<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];
|
|
@@ -129,4 +129,4 @@ export declare const querySyntax: <T extends TObject<import("@sinclair/typebox")
|
|
|
129
129
|
$in: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
130
130
|
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
131
131
|
}>, TObject<X[K_2]>]>>]>>; }>>]>;
|
|
132
|
-
export declare const ObjectIdSchema: () =>
|
|
132
|
+
export declare const ObjectIdSchema: () => 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":";;;;;;;;;;;;;;;;;AAAA,+CAS0B;AAC1B,+CAAiF;AAEjF,oDAAiC;AACjC,oDAAiC;AAQjC;;;;;;GAMG;AACI,MAAM,YAAY,GAAG,CAC1B,MAAgD,EAChD,SAAc,EACG,EAAE,CAAC,mBAAU,CAAC,YAAY,CAAC,MAAa,EAAE,SAAS,CAAC,CAAA;AAH1D,QAAA,YAAY,gBAG8C;AAEvE;;;;;;;;;GASG;AACI,MAAM,gBAAgB,GAAG,CAAC,GAA6B,EAAE,SAAc,EAAoB,EAAE,CAClG,mBAAU,CAAC,gBAAgB,CAAC,GAAU,EAAE,SAAS,CAAC,CAAA;AADvC,QAAA,gBAAgB,oBACuB;AAEpD;;;;GAIG;AACH,SAAgB,UAAU,CAAqB,aAAqB;IAClE,OAAO,cAAI,CAAC,MAAM,CAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAA;AACxE,CAAC;AAFD,gCAEC;AAED,MAAM,WAAW,GAAG,CAAoB,IAAO,EAAE,EAAE;IACjD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACzC,OAAO,cAAI,CAAC,MAAM,CAA4B;QAC5C,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,IAAI,CAAC,MAAM;QACrB,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3C;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AAED;;;;;GAKG;AACH,SAAgB,cAAc,CAAoB,MAAS;IAC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AAC;YAC3B,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC;YAC1B,IAAI;YACJ,GAAG;SACJ,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAChC,CACF;QACD,cAAc;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.9",
|
|
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.9",
|
|
58
58
|
"@sinclair/typebox": "^0.25.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/mocha": "^10.0.1",
|
|
62
|
-
"@types/node": "^20.
|
|
62
|
+
"@types/node": "^20.7.0",
|
|
63
63
|
"mocha": "^10.2.0",
|
|
64
64
|
"shx": "^0.3.4",
|
|
65
|
-
"typescript": "^5.
|
|
65
|
+
"typescript": "^5.2.2"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "64ee98dadf02dac34f31e3cb7b6b10e1f7405bfa"
|
|
68
68
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Type,
|
|
3
|
+
TObject,
|
|
4
|
+
TInteger,
|
|
5
|
+
TOptional,
|
|
6
|
+
TSchema,
|
|
7
|
+
ObjectOptions,
|
|
8
|
+
TIntersect,
|
|
9
|
+
TUnion
|
|
10
|
+
} from '@sinclair/typebox'
|
|
2
11
|
import { jsonSchema, Validator, DataValidatorMap, Ajv } from '@feathersjs/schema'
|
|
3
12
|
|
|
4
13
|
export * from '@sinclair/typebox'
|
|
@@ -17,8 +26,10 @@ export type TDataSchemaMap = {
|
|
|
17
26
|
* @param validator The AJV validation instance
|
|
18
27
|
* @returns A compiled validation function
|
|
19
28
|
*/
|
|
20
|
-
export const getValidator = <T = any, R = T>(
|
|
21
|
-
|
|
29
|
+
export const getValidator = <T = any, R = T>(
|
|
30
|
+
schema: TObject | TIntersect | TUnion<TObject[]>,
|
|
31
|
+
validator: Ajv
|
|
32
|
+
): Validator<T, R> => jsonSchema.getValidator(schema as any, validator)
|
|
22
33
|
|
|
23
34
|
/**
|
|
24
35
|
* Returns compiled validation functions to validate data for the `create`, `update` and `patch`
|