@feathersjs/typebox 5.0.4 → 5.0.5
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 +6 -0
- package/lib/default-schemas.d.ts +35 -35
- package/lib/index.d.ts +65 -80
- package/lib/index.js +19 -60
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +8 -66
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
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.5](https://github.com/feathersjs/feathers/compare/v5.0.4...v5.0.5) (2023-04-28)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **typebox:** Revert to TypeBox 0.25 ([#3183](https://github.com/feathersjs/feathers/issues/3183)) ([cacedf5](https://github.com/feathersjs/feathers/commit/cacedf59e3d2df836777f0cd06ab1b2484ed87c5))
|
|
11
|
+
|
|
6
12
|
## [5.0.4](https://github.com/feathersjs/feathers/compare/v5.0.3...v5.0.4) (2023-04-12)
|
|
7
13
|
|
|
8
14
|
### Bug Fixes
|
package/lib/default-schemas.d.ts
CHANGED
|
@@ -30,13 +30,13 @@ export declare const authenticationSettingsSchema: import("@sinclair/typebox").T
|
|
|
30
30
|
}>;
|
|
31
31
|
export declare const sqlSettingsSchema: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
32
32
|
client: import("@sinclair/typebox").TString<string>;
|
|
33
|
-
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TObject<{
|
|
34
|
-
host: import("@sinclair/typebox").
|
|
35
|
-
port: import("@sinclair/typebox").
|
|
36
|
-
user: import("@sinclair/typebox").
|
|
37
|
-
password: import("@sinclair/typebox").
|
|
38
|
-
database: import("@sinclair/typebox").
|
|
39
|
-
}
|
|
33
|
+
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TPartial<import("@sinclair/typebox").TObject<{
|
|
34
|
+
host: import("@sinclair/typebox").TString<string>;
|
|
35
|
+
port: import("@sinclair/typebox").TNumber;
|
|
36
|
+
user: import("@sinclair/typebox").TString<string>;
|
|
37
|
+
password: import("@sinclair/typebox").TString<string>;
|
|
38
|
+
database: import("@sinclair/typebox").TString<string>;
|
|
39
|
+
}>>]>;
|
|
40
40
|
pool: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
41
41
|
min: import("@sinclair/typebox").TNumber;
|
|
42
42
|
max: import("@sinclair/typebox").TNumber;
|
|
@@ -80,13 +80,13 @@ export declare const defaultAppConfiguration: import("@sinclair/typebox").TObjec
|
|
|
80
80
|
mongodb: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
|
|
81
81
|
mysql: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
82
82
|
client: import("@sinclair/typebox").TString<string>;
|
|
83
|
-
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TObject<{
|
|
84
|
-
host: import("@sinclair/typebox").
|
|
85
|
-
port: import("@sinclair/typebox").
|
|
86
|
-
user: import("@sinclair/typebox").
|
|
87
|
-
password: import("@sinclair/typebox").
|
|
88
|
-
database: import("@sinclair/typebox").
|
|
89
|
-
}
|
|
83
|
+
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TPartial<import("@sinclair/typebox").TObject<{
|
|
84
|
+
host: import("@sinclair/typebox").TString<string>;
|
|
85
|
+
port: import("@sinclair/typebox").TNumber;
|
|
86
|
+
user: import("@sinclair/typebox").TString<string>;
|
|
87
|
+
password: import("@sinclair/typebox").TString<string>;
|
|
88
|
+
database: import("@sinclair/typebox").TString<string>;
|
|
89
|
+
}>>]>;
|
|
90
90
|
pool: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
91
91
|
min: import("@sinclair/typebox").TNumber;
|
|
92
92
|
max: import("@sinclair/typebox").TNumber;
|
|
@@ -94,13 +94,13 @@ export declare const defaultAppConfiguration: import("@sinclair/typebox").TObjec
|
|
|
94
94
|
}>>;
|
|
95
95
|
postgresql: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
96
96
|
client: import("@sinclair/typebox").TString<string>;
|
|
97
|
-
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TObject<{
|
|
98
|
-
host: import("@sinclair/typebox").
|
|
99
|
-
port: import("@sinclair/typebox").
|
|
100
|
-
user: import("@sinclair/typebox").
|
|
101
|
-
password: import("@sinclair/typebox").
|
|
102
|
-
database: import("@sinclair/typebox").
|
|
103
|
-
}
|
|
97
|
+
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TPartial<import("@sinclair/typebox").TObject<{
|
|
98
|
+
host: import("@sinclair/typebox").TString<string>;
|
|
99
|
+
port: import("@sinclair/typebox").TNumber;
|
|
100
|
+
user: import("@sinclair/typebox").TString<string>;
|
|
101
|
+
password: import("@sinclair/typebox").TString<string>;
|
|
102
|
+
database: import("@sinclair/typebox").TString<string>;
|
|
103
|
+
}>>]>;
|
|
104
104
|
pool: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
105
105
|
min: import("@sinclair/typebox").TNumber;
|
|
106
106
|
max: import("@sinclair/typebox").TNumber;
|
|
@@ -108,13 +108,13 @@ export declare const defaultAppConfiguration: import("@sinclair/typebox").TObjec
|
|
|
108
108
|
}>>;
|
|
109
109
|
sqlite: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
110
110
|
client: import("@sinclair/typebox").TString<string>;
|
|
111
|
-
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TObject<{
|
|
112
|
-
host: import("@sinclair/typebox").
|
|
113
|
-
port: import("@sinclair/typebox").
|
|
114
|
-
user: import("@sinclair/typebox").
|
|
115
|
-
password: import("@sinclair/typebox").
|
|
116
|
-
database: import("@sinclair/typebox").
|
|
117
|
-
}
|
|
111
|
+
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TPartial<import("@sinclair/typebox").TObject<{
|
|
112
|
+
host: import("@sinclair/typebox").TString<string>;
|
|
113
|
+
port: import("@sinclair/typebox").TNumber;
|
|
114
|
+
user: import("@sinclair/typebox").TString<string>;
|
|
115
|
+
password: import("@sinclair/typebox").TString<string>;
|
|
116
|
+
database: import("@sinclair/typebox").TString<string>;
|
|
117
|
+
}>>]>;
|
|
118
118
|
pool: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
119
119
|
min: import("@sinclair/typebox").TNumber;
|
|
120
120
|
max: import("@sinclair/typebox").TNumber;
|
|
@@ -122,13 +122,13 @@ export declare const defaultAppConfiguration: import("@sinclair/typebox").TObjec
|
|
|
122
122
|
}>>;
|
|
123
123
|
mssql: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
124
124
|
client: import("@sinclair/typebox").TString<string>;
|
|
125
|
-
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TObject<{
|
|
126
|
-
host: import("@sinclair/typebox").
|
|
127
|
-
port: import("@sinclair/typebox").
|
|
128
|
-
user: import("@sinclair/typebox").
|
|
129
|
-
password: import("@sinclair/typebox").
|
|
130
|
-
database: import("@sinclair/typebox").
|
|
131
|
-
}
|
|
125
|
+
connection: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, import("@sinclair/typebox").TPartial<import("@sinclair/typebox").TObject<{
|
|
126
|
+
host: import("@sinclair/typebox").TString<string>;
|
|
127
|
+
port: import("@sinclair/typebox").TNumber;
|
|
128
|
+
user: import("@sinclair/typebox").TString<string>;
|
|
129
|
+
password: import("@sinclair/typebox").TString<string>;
|
|
130
|
+
database: import("@sinclair/typebox").TString<string>;
|
|
131
|
+
}>>]>;
|
|
132
132
|
pool: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
133
133
|
min: import("@sinclair/typebox").TNumber;
|
|
134
134
|
max: import("@sinclair/typebox").TNumber;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
import { TObject, TInteger, TOptional, TSchema,
|
|
1
|
+
import { TObject, TInteger, TOptional, TSchema, ObjectOptions } from '@sinclair/typebox';
|
|
2
2
|
import { Validator, DataValidatorMap, Ajv } from '@feathersjs/schema';
|
|
3
3
|
export * from '@sinclair/typebox';
|
|
4
4
|
export * from './default-schemas';
|
|
5
|
-
/**
|
|
6
|
-
* Feathers TypeBox customisations. Implements the 0.25.0 fallback for Intersect types.
|
|
7
|
-
* @see https://github.com/sinclairzx81/typebox/issues/373
|
|
8
|
-
*/
|
|
9
|
-
export declare class FeathersTypeBuilder extends ExtendedTypeBuilder {
|
|
10
|
-
/** `[Standard]` Creates a Intersect type */
|
|
11
|
-
Intersect(allOf: [], options?: SchemaOptions): TNever;
|
|
12
|
-
/** `[Standard]` Creates a Intersect type */
|
|
13
|
-
Intersect<T extends [TObject]>(allOf: [...T], options?: SchemaOptions): T[0];
|
|
14
|
-
Intersect<T extends TObject[]>(allOf: [...T], options?: IntersectOptions): TIntersect<T>;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Exports our own type builder
|
|
18
|
-
*/
|
|
19
|
-
export declare const Type: FeathersTypeBuilder;
|
|
20
5
|
export type TDataSchemaMap = {
|
|
21
6
|
create: TObject;
|
|
22
7
|
update?: TObject;
|
|
@@ -29,7 +14,7 @@ export type TDataSchemaMap = {
|
|
|
29
14
|
* @param validator The AJV validation instance
|
|
30
15
|
* @returns A compiled validation function
|
|
31
16
|
*/
|
|
32
|
-
export declare const getValidator: <T = any, R = T>(schema: TObject
|
|
17
|
+
export declare const getValidator: <T = any, R = T>(schema: TObject, validator: Ajv) => Validator<T, R>;
|
|
33
18
|
/**
|
|
34
19
|
* Returns compiled validation functions to validate data for the `create`, `update` and `patch`
|
|
35
20
|
* service methods. If not passed explicitly, the `update` validator will be the same as the `create`
|
|
@@ -53,7 +38,7 @@ export declare function StringEnum<T extends string[]>(allowedValues: [...T]): i
|
|
|
53
38
|
* @param schema The TypeBox object schema
|
|
54
39
|
* @returns The `$sort` syntax schema
|
|
55
40
|
*/
|
|
56
|
-
export declare function sortDefinition<T extends TObject
|
|
41
|
+
export declare function sortDefinition<T extends TObject>(schema: T): TObject<T["properties"] extends infer T_1 ? { [K in keyof T_1]: TOptional<TInteger>; } : never>;
|
|
57
42
|
/**
|
|
58
43
|
* Returns the standard Feathers query syntax for a property schema,
|
|
59
44
|
* including operators like `$gt`, `$lt` etc. for a single property
|
|
@@ -64,15 +49,15 @@ export declare function sortDefinition<T extends TObject | TIntersect>(schema: T
|
|
|
64
49
|
*/
|
|
65
50
|
export declare const queryProperty: <T extends TSchema, X extends {
|
|
66
51
|
[key: string]: TSchema;
|
|
67
|
-
}>(def: T, extension?: X) => TOptional<import("@sinclair/typebox").TUnion<[T, import("@sinclair/typebox").
|
|
68
|
-
$gt: T
|
|
69
|
-
$gte: T
|
|
70
|
-
$lt: T
|
|
71
|
-
$lte: T
|
|
72
|
-
$ne: T
|
|
73
|
-
$in:
|
|
74
|
-
$nin:
|
|
75
|
-
}
|
|
52
|
+
}>(def: T, extension?: X) => TOptional<import("@sinclair/typebox").TUnion<[T, import("@sinclair/typebox").TPartial<import("@sinclair/typebox").TIntersect<[TObject<{
|
|
53
|
+
$gt: T;
|
|
54
|
+
$gte: T;
|
|
55
|
+
$lt: T;
|
|
56
|
+
$lte: T;
|
|
57
|
+
$ne: T;
|
|
58
|
+
$in: import("@sinclair/typebox").TArray<T>;
|
|
59
|
+
$nin: import("@sinclair/typebox").TArray<T>;
|
|
60
|
+
}>, TObject<X>]>>]>>;
|
|
76
61
|
/**
|
|
77
62
|
* Creates a Feathers query syntax schema for the properties defined in `definition`.
|
|
78
63
|
*
|
|
@@ -80,17 +65,17 @@ export declare const queryProperty: <T extends TSchema, X extends {
|
|
|
80
65
|
* @param extensions Additional properties to add to a property query
|
|
81
66
|
* @returns The Feathers query syntax schema
|
|
82
67
|
*/
|
|
83
|
-
export declare const queryProperties: <T extends TObject<import("@sinclair/typebox").TProperties
|
|
68
|
+
export declare const queryProperties: <T extends TObject<import("@sinclair/typebox").TProperties>, X extends T["properties"] extends infer T_1 ? { [K in keyof T_1]?: {
|
|
84
69
|
[key: string]: TSchema;
|
|
85
|
-
}; } : 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").
|
|
86
|
-
$gt: T["properties"][K_1]
|
|
87
|
-
$gte: T["properties"][K_1]
|
|
88
|
-
$lt: T["properties"][K_1]
|
|
89
|
-
$lte: T["properties"][K_1]
|
|
90
|
-
$ne: T["properties"][K_1]
|
|
91
|
-
$in:
|
|
92
|
-
$nin:
|
|
93
|
-
}
|
|
70
|
+
}; } : 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<{
|
|
71
|
+
$gt: T["properties"][K_1];
|
|
72
|
+
$gte: T["properties"][K_1];
|
|
73
|
+
$lt: T["properties"][K_1];
|
|
74
|
+
$lte: T["properties"][K_1];
|
|
75
|
+
$ne: T["properties"][K_1];
|
|
76
|
+
$in: import("@sinclair/typebox").TArray<T["properties"][K_1]>;
|
|
77
|
+
$nin: import("@sinclair/typebox").TArray<T["properties"][K_1]>;
|
|
78
|
+
}>, TObject<X[K_1]>]>>]>>; } : never>>;
|
|
94
79
|
/**
|
|
95
80
|
* Creates a TypeBox schema for the complete Feathers query syntax including `$limit`, $skip`, `$or`
|
|
96
81
|
* and `$sort` and `$select` for the allowed properties.
|
|
@@ -100,48 +85,48 @@ export declare const queryProperties: <T extends TObject<import("@sinclair/typeb
|
|
|
100
85
|
* @param options Options for the TypeBox object schema
|
|
101
86
|
* @returns A TypeBox object representing the complete Feathers query syntax for the given properties
|
|
102
87
|
*/
|
|
103
|
-
export declare const querySyntax: <T extends TObject<import("@sinclair/typebox").TProperties
|
|
88
|
+
export declare const querySyntax: <T extends TObject<import("@sinclair/typebox").TProperties>, X extends T["properties"] extends infer T_1 ? { [K in keyof T_1]?: {
|
|
104
89
|
[key: string]: TSchema;
|
|
105
|
-
}; } : never>(type: T, extensions?: X, options?: ObjectOptions) => import("@sinclair/typebox").
|
|
106
|
-
$limit:
|
|
107
|
-
$skip:
|
|
108
|
-
$sort:
|
|
109
|
-
$select:
|
|
110
|
-
$and:
|
|
111
|
-
$gt: T["properties"][K_2]
|
|
112
|
-
$gte: T["properties"][K_2]
|
|
113
|
-
$lt: T["properties"][K_2]
|
|
114
|
-
$lte: T["properties"][K_2]
|
|
115
|
-
$ne: T["properties"][K_2]
|
|
116
|
-
$in:
|
|
117
|
-
$nin:
|
|
118
|
-
}
|
|
119
|
-
$or: import("@sinclair/typebox").TArray<TOptional<TObject<T["properties"] extends infer
|
|
120
|
-
$gt: T["properties"][K_2]
|
|
121
|
-
$gte: T["properties"][K_2]
|
|
122
|
-
$lt: T["properties"][K_2]
|
|
123
|
-
$lte: T["properties"][K_2]
|
|
124
|
-
$ne: T["properties"][K_2]
|
|
125
|
-
$in:
|
|
126
|
-
$nin:
|
|
127
|
-
}
|
|
128
|
-
}>]
|
|
129
|
-
$or:
|
|
130
|
-
$gt: T["properties"][K_2]
|
|
131
|
-
$gte: T["properties"][K_2]
|
|
132
|
-
$lt: T["properties"][K_2]
|
|
133
|
-
$lte: T["properties"][K_2]
|
|
134
|
-
$ne: T["properties"][K_2]
|
|
135
|
-
$in:
|
|
136
|
-
$nin:
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
$gt: T["properties"][K_2]
|
|
140
|
-
$gte: T["properties"][K_2]
|
|
141
|
-
$lt: T["properties"][K_2]
|
|
142
|
-
$lte: T["properties"][K_2]
|
|
143
|
-
$ne: T["properties"][K_2]
|
|
144
|
-
$in:
|
|
145
|
-
$nin:
|
|
146
|
-
}
|
|
90
|
+
}; } : never>(type: T, extensions?: X, options?: ObjectOptions) => import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TPartial<TObject<{
|
|
91
|
+
$limit: import("@sinclair/typebox").TNumber;
|
|
92
|
+
$skip: import("@sinclair/typebox").TNumber;
|
|
93
|
+
$sort: TObject<T["properties"] extends infer T_2 ? { [K_1 in keyof T_2]: TOptional<TInteger>; } : never>;
|
|
94
|
+
$select: import("@sinclair/typebox").TUnsafe<(keyof T["properties"])[]>;
|
|
95
|
+
$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<{
|
|
96
|
+
$gt: T["properties"][K_2];
|
|
97
|
+
$gte: T["properties"][K_2];
|
|
98
|
+
$lt: T["properties"][K_2];
|
|
99
|
+
$lte: T["properties"][K_2];
|
|
100
|
+
$ne: T["properties"][K_2];
|
|
101
|
+
$in: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
102
|
+
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
103
|
+
}>, TObject<X[K_2]>]>>]>>; } : never>>, TObject<{
|
|
104
|
+
$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<{
|
|
105
|
+
$gt: T["properties"][K_2];
|
|
106
|
+
$gte: T["properties"][K_2];
|
|
107
|
+
$lt: T["properties"][K_2];
|
|
108
|
+
$lte: T["properties"][K_2];
|
|
109
|
+
$ne: T["properties"][K_2];
|
|
110
|
+
$in: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
111
|
+
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
112
|
+
}>, TObject<X[K_2]>]>>]>>; } : never>>>;
|
|
113
|
+
}>]>>;
|
|
114
|
+
$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<{
|
|
115
|
+
$gt: T["properties"][K_2];
|
|
116
|
+
$gte: T["properties"][K_2];
|
|
117
|
+
$lt: T["properties"][K_2];
|
|
118
|
+
$lte: T["properties"][K_2];
|
|
119
|
+
$ne: T["properties"][K_2];
|
|
120
|
+
$in: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
121
|
+
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
122
|
+
}>, TObject<X[K_2]>]>>]>>; } : never>>>;
|
|
123
|
+
}>>, 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<{
|
|
124
|
+
$gt: T["properties"][K_2];
|
|
125
|
+
$gte: T["properties"][K_2];
|
|
126
|
+
$lt: T["properties"][K_2];
|
|
127
|
+
$lte: T["properties"][K_2];
|
|
128
|
+
$ne: T["properties"][K_2];
|
|
129
|
+
$in: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
130
|
+
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
131
|
+
}>, TObject<X[K_2]>]>>]>>; } : never>>]>;
|
|
147
132
|
export declare const ObjectIdSchema: () => import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, TObject<{}>]>;
|
package/lib/index.js
CHANGED
|
@@ -14,52 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.ObjectIdSchema = exports.querySyntax = exports.queryProperties = exports.queryProperty = exports.sortDefinition = exports.StringEnum = exports.getDataValidator = exports.getValidator =
|
|
17
|
+
exports.ObjectIdSchema = exports.querySyntax = exports.queryProperties = exports.queryProperty = exports.sortDefinition = exports.StringEnum = exports.getDataValidator = exports.getValidator = void 0;
|
|
18
18
|
const typebox_1 = require("@sinclair/typebox");
|
|
19
19
|
const schema_1 = require("@feathersjs/schema");
|
|
20
20
|
__exportStar(require("@sinclair/typebox"), exports);
|
|
21
21
|
__exportStar(require("./default-schemas"), exports);
|
|
22
|
-
/**
|
|
23
|
-
* Feathers TypeBox customisations. Implements the 0.25.0 fallback for Intersect types.
|
|
24
|
-
* @see https://github.com/sinclairzx81/typebox/issues/373
|
|
25
|
-
*/
|
|
26
|
-
class FeathersTypeBuilder extends typebox_1.ExtendedTypeBuilder {
|
|
27
|
-
Intersect(allOf, options = {}) {
|
|
28
|
-
const [required, optional] = [new Set(), new Set()];
|
|
29
|
-
for (const object of allOf) {
|
|
30
|
-
for (const [key, property] of Object.entries(object.properties)) {
|
|
31
|
-
if (typebox_1.TypeGuard.TOptional(property) || typebox_1.TypeGuard.TReadonlyOptional(property))
|
|
32
|
-
optional.add(key);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
for (const object of allOf) {
|
|
36
|
-
for (const key of Object.keys(object.properties)) {
|
|
37
|
-
if (!optional.has(key))
|
|
38
|
-
required.add(key);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const properties = {};
|
|
42
|
-
for (const object of allOf) {
|
|
43
|
-
for (const [key, schema] of Object.entries(object.properties)) {
|
|
44
|
-
properties[key] =
|
|
45
|
-
properties[key] === undefined
|
|
46
|
-
? schema
|
|
47
|
-
: { [typebox_1.Kind]: 'Union', anyOf: [properties[key], { ...schema }] };
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (required.size > 0) {
|
|
51
|
-
return { ...options, [typebox_1.Kind]: 'Object', type: 'object', properties, required: [...required] };
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return { ...options, [typebox_1.Kind]: 'Object', type: 'object', properties };
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.FeathersTypeBuilder = FeathersTypeBuilder;
|
|
59
|
-
/**
|
|
60
|
-
* Exports our own type builder
|
|
61
|
-
*/
|
|
62
|
-
exports.Type = new FeathersTypeBuilder();
|
|
63
22
|
/**
|
|
64
23
|
* Returns a compiled validation function for a TypeBox object and AJV validator instance.
|
|
65
24
|
*
|
|
@@ -87,12 +46,12 @@ exports.getDataValidator = getDataValidator;
|
|
|
87
46
|
* @returns TypeBox.Type
|
|
88
47
|
*/
|
|
89
48
|
function StringEnum(allowedValues) {
|
|
90
|
-
return
|
|
49
|
+
return typebox_1.Type.Unsafe({ type: 'string', enum: allowedValues });
|
|
91
50
|
}
|
|
92
51
|
exports.StringEnum = StringEnum;
|
|
93
52
|
const arrayOfKeys = (type) => {
|
|
94
53
|
const keys = Object.keys(type.properties);
|
|
95
|
-
return
|
|
54
|
+
return typebox_1.Type.Unsafe({
|
|
96
55
|
type: 'array',
|
|
97
56
|
maxItems: keys.length,
|
|
98
57
|
items: {
|
|
@@ -110,10 +69,10 @@ const arrayOfKeys = (type) => {
|
|
|
110
69
|
function sortDefinition(schema) {
|
|
111
70
|
const properties = Object.keys(schema.properties).reduce((res, key) => {
|
|
112
71
|
const result = res;
|
|
113
|
-
result[key] =
|
|
72
|
+
result[key] = typebox_1.Type.Optional(typebox_1.Type.Integer({ minimum: -1, maximum: 1 }));
|
|
114
73
|
return result;
|
|
115
74
|
}, {});
|
|
116
|
-
return
|
|
75
|
+
return typebox_1.Type.Object(properties, { additionalProperties: false });
|
|
117
76
|
}
|
|
118
77
|
exports.sortDefinition = sortDefinition;
|
|
119
78
|
/**
|
|
@@ -124,19 +83,19 @@ exports.sortDefinition = sortDefinition;
|
|
|
124
83
|
* @param extension Additional properties to add to the property query
|
|
125
84
|
* @returns The Feathers query syntax schema
|
|
126
85
|
*/
|
|
127
|
-
const queryProperty = (def, extension = {}) =>
|
|
86
|
+
const queryProperty = (def, extension = {}) => typebox_1.Type.Optional(typebox_1.Type.Union([
|
|
128
87
|
def,
|
|
129
|
-
|
|
130
|
-
|
|
88
|
+
typebox_1.Type.Partial(typebox_1.Type.Intersect([
|
|
89
|
+
typebox_1.Type.Object({
|
|
131
90
|
$gt: def,
|
|
132
91
|
$gte: def,
|
|
133
92
|
$lt: def,
|
|
134
93
|
$lte: def,
|
|
135
94
|
$ne: def,
|
|
136
|
-
$in:
|
|
137
|
-
$nin:
|
|
95
|
+
$in: typebox_1.Type.Array(def),
|
|
96
|
+
$nin: typebox_1.Type.Array(def)
|
|
138
97
|
}),
|
|
139
|
-
|
|
98
|
+
typebox_1.Type.Object(extension)
|
|
140
99
|
], { additionalProperties: false }))
|
|
141
100
|
]));
|
|
142
101
|
exports.queryProperty = queryProperty;
|
|
@@ -154,7 +113,7 @@ const queryProperties = (definition, extensions = {}) => {
|
|
|
154
113
|
result[key] = (0, exports.queryProperty)(value, extensions[key]);
|
|
155
114
|
return result;
|
|
156
115
|
}, {});
|
|
157
|
-
return
|
|
116
|
+
return typebox_1.Type.Optional(typebox_1.Type.Object(properties, { additionalProperties: false }));
|
|
158
117
|
};
|
|
159
118
|
exports.queryProperties = queryProperties;
|
|
160
119
|
/**
|
|
@@ -168,12 +127,12 @@ exports.queryProperties = queryProperties;
|
|
|
168
127
|
*/
|
|
169
128
|
const querySyntax = (type, extensions = {}, options = { additionalProperties: false }) => {
|
|
170
129
|
const propertySchema = (0, exports.queryProperties)(type, extensions);
|
|
171
|
-
const $or =
|
|
172
|
-
const $and =
|
|
173
|
-
return
|
|
174
|
-
|
|
175
|
-
$limit:
|
|
176
|
-
$skip:
|
|
130
|
+
const $or = typebox_1.Type.Array(propertySchema);
|
|
131
|
+
const $and = typebox_1.Type.Array(typebox_1.Type.Union([propertySchema, typebox_1.Type.Object({ $or })]));
|
|
132
|
+
return typebox_1.Type.Intersect([
|
|
133
|
+
typebox_1.Type.Partial(typebox_1.Type.Object({
|
|
134
|
+
$limit: typebox_1.Type.Number({ minimum: 0 }),
|
|
135
|
+
$skip: typebox_1.Type.Number({ minimum: 0 }),
|
|
177
136
|
$sort: sortDefinition(type),
|
|
178
137
|
$select: arrayOfKeys(type),
|
|
179
138
|
$and,
|
|
@@ -183,6 +142,6 @@ const querySyntax = (type, extensions = {}, options = { additionalProperties: fa
|
|
|
183
142
|
], options);
|
|
184
143
|
};
|
|
185
144
|
exports.querySyntax = querySyntax;
|
|
186
|
-
const ObjectIdSchema = () =>
|
|
145
|
+
const ObjectIdSchema = () => typebox_1.Type.Union([typebox_1.Type.String({ objectid: true }), typebox_1.Type.Object({}, { additionalProperties: false })]);
|
|
187
146
|
exports.ObjectIdSchema = ObjectIdSchema;
|
|
188
147
|
//# sourceMappingURL=index.js.map
|
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,+CAA8F;AAC9F,+CAAiF;AAEjF,oDAAiC;AACjC,oDAAiC;AAQjC;;;;;;GAMG;AACI,MAAM,YAAY,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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.5",
|
|
5
5
|
"homepage": "https://feathersjs.com",
|
|
6
6
|
"main": "lib/",
|
|
7
7
|
"types": "lib/",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@feathersjs/schema": "^5.0.
|
|
58
|
-
"@sinclair/typebox": "^0.
|
|
57
|
+
"@feathersjs/schema": "^5.0.5",
|
|
58
|
+
"@sinclair/typebox": "^0.25.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/mocha": "^10.0.1",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"shx": "^0.3.4",
|
|
65
65
|
"typescript": "^5.0.3"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "42bd5e40ec73b10939b9a008ae8e49c39a191009"
|
|
68
68
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,67 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TObject,
|
|
3
|
-
TInteger,
|
|
4
|
-
TOptional,
|
|
5
|
-
TSchema,
|
|
6
|
-
TIntersect,
|
|
7
|
-
ObjectOptions,
|
|
8
|
-
ExtendedTypeBuilder,
|
|
9
|
-
SchemaOptions,
|
|
10
|
-
TNever,
|
|
11
|
-
IntersectOptions,
|
|
12
|
-
TypeGuard,
|
|
13
|
-
Kind
|
|
14
|
-
} from '@sinclair/typebox'
|
|
1
|
+
import { Type, TObject, TInteger, TOptional, TSchema, ObjectOptions } from '@sinclair/typebox'
|
|
15
2
|
import { jsonSchema, Validator, DataValidatorMap, Ajv } from '@feathersjs/schema'
|
|
16
3
|
|
|
17
4
|
export * from '@sinclair/typebox'
|
|
18
5
|
export * from './default-schemas'
|
|
19
6
|
|
|
20
|
-
/**
|
|
21
|
-
* Feathers TypeBox customisations. Implements the 0.25.0 fallback for Intersect types.
|
|
22
|
-
* @see https://github.com/sinclairzx81/typebox/issues/373
|
|
23
|
-
*/
|
|
24
|
-
export class FeathersTypeBuilder extends ExtendedTypeBuilder {
|
|
25
|
-
/** `[Standard]` Creates a Intersect type */
|
|
26
|
-
public Intersect(allOf: [], options?: SchemaOptions): TNever
|
|
27
|
-
/** `[Standard]` Creates a Intersect type */
|
|
28
|
-
public Intersect<T extends [TObject]>(allOf: [...T], options?: SchemaOptions): T[0]
|
|
29
|
-
// /** `[Standard]` Creates a Intersect type */
|
|
30
|
-
public Intersect<T extends TObject[]>(allOf: [...T], options?: IntersectOptions): TIntersect<T>
|
|
31
|
-
public Intersect(allOf: TObject[], options: IntersectOptions = {}) {
|
|
32
|
-
const [required, optional] = [new Set<string>(), new Set<string>()]
|
|
33
|
-
for (const object of allOf) {
|
|
34
|
-
for (const [key, property] of Object.entries(object.properties)) {
|
|
35
|
-
if (TypeGuard.TOptional(property) || TypeGuard.TReadonlyOptional(property)) optional.add(key)
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
for (const object of allOf) {
|
|
39
|
-
for (const key of Object.keys(object.properties)) {
|
|
40
|
-
if (!optional.has(key)) required.add(key)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
const properties = {} as Record<string, any>
|
|
44
|
-
for (const object of allOf) {
|
|
45
|
-
for (const [key, schema] of Object.entries(object.properties)) {
|
|
46
|
-
properties[key] =
|
|
47
|
-
properties[key] === undefined
|
|
48
|
-
? schema
|
|
49
|
-
: { [Kind]: 'Union', anyOf: [properties[key], { ...schema }] }
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (required.size > 0) {
|
|
53
|
-
return { ...options, [Kind]: 'Object', type: 'object', properties, required: [...required] } as any
|
|
54
|
-
} else {
|
|
55
|
-
return { ...options, [Kind]: 'Object', type: 'object', properties } as any
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Exports our own type builder
|
|
62
|
-
*/
|
|
63
|
-
export const Type = new FeathersTypeBuilder()
|
|
64
|
-
|
|
65
7
|
export type TDataSchemaMap = {
|
|
66
8
|
create: TObject
|
|
67
9
|
update?: TObject
|
|
@@ -75,7 +17,7 @@ export type TDataSchemaMap = {
|
|
|
75
17
|
* @param validator The AJV validation instance
|
|
76
18
|
* @returns A compiled validation function
|
|
77
19
|
*/
|
|
78
|
-
export const getValidator = <T = any, R = T>(schema: TObject
|
|
20
|
+
export const getValidator = <T = any, R = T>(schema: TObject, validator: Ajv): Validator<T, R> =>
|
|
79
21
|
jsonSchema.getValidator(schema as any, validator)
|
|
80
22
|
|
|
81
23
|
/**
|
|
@@ -100,7 +42,7 @@ export function StringEnum<T extends string[]>(allowedValues: [...T]) {
|
|
|
100
42
|
return Type.Unsafe<T[number]>({ type: 'string', enum: allowedValues })
|
|
101
43
|
}
|
|
102
44
|
|
|
103
|
-
const arrayOfKeys = <T extends TObject
|
|
45
|
+
const arrayOfKeys = <T extends TObject>(type: T) => {
|
|
104
46
|
const keys = Object.keys(type.properties)
|
|
105
47
|
return Type.Unsafe<(keyof T['properties'])[]>({
|
|
106
48
|
type: 'array',
|
|
@@ -118,7 +60,7 @@ const arrayOfKeys = <T extends TObject | TIntersect>(type: T) => {
|
|
|
118
60
|
* @param schema The TypeBox object schema
|
|
119
61
|
* @returns The `$sort` syntax schema
|
|
120
62
|
*/
|
|
121
|
-
export function sortDefinition<T extends TObject
|
|
63
|
+
export function sortDefinition<T extends TObject>(schema: T) {
|
|
122
64
|
const properties = Object.keys(schema.properties).reduce((res, key) => {
|
|
123
65
|
const result = res as any
|
|
124
66
|
|
|
@@ -146,7 +88,7 @@ export const queryProperty = <T extends TSchema, X extends { [key: string]: TSch
|
|
|
146
88
|
Type.Union([
|
|
147
89
|
def,
|
|
148
90
|
Type.Partial(
|
|
149
|
-
Type.
|
|
91
|
+
Type.Intersect(
|
|
150
92
|
[
|
|
151
93
|
Type.Object({
|
|
152
94
|
$gt: def,
|
|
@@ -177,7 +119,7 @@ type QueryProperty<T extends TSchema, X extends { [key: string]: TSchema }> = Re
|
|
|
177
119
|
* @returns The Feathers query syntax schema
|
|
178
120
|
*/
|
|
179
121
|
export const queryProperties = <
|
|
180
|
-
T extends TObject
|
|
122
|
+
T extends TObject,
|
|
181
123
|
X extends { [K in keyof T['properties']]?: { [key: string]: TSchema } }
|
|
182
124
|
>(
|
|
183
125
|
definition: T,
|
|
@@ -205,7 +147,7 @@ export const queryProperties = <
|
|
|
205
147
|
* @returns A TypeBox object representing the complete Feathers query syntax for the given properties
|
|
206
148
|
*/
|
|
207
149
|
export const querySyntax = <
|
|
208
|
-
T extends TObject
|
|
150
|
+
T extends TObject,
|
|
209
151
|
X extends { [K in keyof T['properties']]?: { [key: string]: TSchema } }
|
|
210
152
|
>(
|
|
211
153
|
type: T,
|
|
@@ -216,7 +158,7 @@ export const querySyntax = <
|
|
|
216
158
|
const $or = Type.Array(propertySchema)
|
|
217
159
|
const $and = Type.Array(Type.Union([propertySchema, Type.Object({ $or })]))
|
|
218
160
|
|
|
219
|
-
return Type.
|
|
161
|
+
return Type.Intersect(
|
|
220
162
|
[
|
|
221
163
|
Type.Partial(
|
|
222
164
|
Type.Object(
|