@feathersjs/typebox 5.0.0-pre.34 → 5.0.0-pre.36
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 +15 -0
- package/LICENSE +1 -2
- package/README.md +1 -1
- package/lib/default-schemas.d.ts +55 -5
- package/lib/default-schemas.js +14 -1
- package/lib/default-schemas.js.map +1 -1
- package/lib/index.d.ts +49 -40
- package/lib/index.js +22 -16
- package/lib/index.js.map +1 -1
- package/package.json +8 -8
- package/src/default-schemas.ts +18 -1
- package/src/index.ts +43 -24
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
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.0-pre.36](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.35...v5.0.0-pre.36) (2023-01-29)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **configuration:** Add pool and connection object to SQL database default configuration ([#3023](https://github.com/feathersjs/feathers/issues/3023)) ([092c749](https://github.com/feathersjs/feathers/commit/092c749d43f7da4d019576d1210fe7d3719a44a2))
|
|
11
|
+
- **schema:** Fix TypeBox extension value query syntax inference ([#3010](https://github.com/feathersjs/feathers/issues/3010)) ([f1c7a76](https://github.com/feathersjs/feathers/commit/f1c7a76586bbb8aed66ef866c3dcd666d79f3a24))
|
|
12
|
+
- Update all dependencies ([#3024](https://github.com/feathersjs/feathers/issues/3024)) ([283dc47](https://github.com/feathersjs/feathers/commit/283dc4798d85584bc031e6e54b83b4ea77d1edd0))
|
|
13
|
+
|
|
14
|
+
# [5.0.0-pre.35](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.34...v5.0.0-pre.35) (2023-01-12)
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
- **generators:** Move core code generators to shared generators package ([#2982](https://github.com/feathersjs/feathers/issues/2982)) ([0328d22](https://github.com/feathersjs/feathers/commit/0328d2292153870bc43958f73d2c6f288a8cec17))
|
|
19
|
+
- **schema:** Allow to add additional operators to the query syntax ([#2941](https://github.com/feathersjs/feathers/issues/2941)) ([f324940](https://github.com/feathersjs/feathers/commit/f324940d5795b41e8c6fc113defb0beb7ab03a0a))
|
|
20
|
+
|
|
6
21
|
# [5.0.0-pre.34](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.33...v5.0.0-pre.34) (2022-12-14)
|
|
7
22
|
|
|
8
23
|
### Bug Fixes
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2023 Feathers Contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
22
|
-
|
package/README.md
CHANGED
|
@@ -18,6 +18,6 @@ Refer to the [Feathers documentation](https://docs.feathersjs.com) for more deta
|
|
|
18
18
|
|
|
19
19
|
## License
|
|
20
20
|
|
|
21
|
-
Copyright (c)
|
|
21
|
+
Copyright (c) 2023 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors)
|
|
22
22
|
|
|
23
23
|
Licensed under the [MIT license](LICENSE).
|
package/lib/default-schemas.d.ts
CHANGED
|
@@ -30,7 +30,17 @@ 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").TString<string
|
|
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
|
+
pool: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
41
|
+
min: import("@sinclair/typebox").TNumber;
|
|
42
|
+
max: import("@sinclair/typebox").TNumber;
|
|
43
|
+
}>>;
|
|
34
44
|
}>>;
|
|
35
45
|
export declare const defaultAppConfiguration: import("@sinclair/typebox").TObject<{
|
|
36
46
|
authentication: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
@@ -70,19 +80,59 @@ export declare const defaultAppConfiguration: import("@sinclair/typebox").TObjec
|
|
|
70
80
|
mongodb: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString<string>>;
|
|
71
81
|
mysql: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
72
82
|
client: import("@sinclair/typebox").TString<string>;
|
|
73
|
-
connection: import("@sinclair/typebox").TString<string
|
|
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
|
+
pool: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
91
|
+
min: import("@sinclair/typebox").TNumber;
|
|
92
|
+
max: import("@sinclair/typebox").TNumber;
|
|
93
|
+
}>>;
|
|
74
94
|
}>>;
|
|
75
95
|
postgresql: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
76
96
|
client: import("@sinclair/typebox").TString<string>;
|
|
77
|
-
connection: import("@sinclair/typebox").TString<string
|
|
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
|
+
pool: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
105
|
+
min: import("@sinclair/typebox").TNumber;
|
|
106
|
+
max: import("@sinclair/typebox").TNumber;
|
|
107
|
+
}>>;
|
|
78
108
|
}>>;
|
|
79
109
|
sqlite: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
80
110
|
client: import("@sinclair/typebox").TString<string>;
|
|
81
|
-
connection: import("@sinclair/typebox").TString<string
|
|
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
|
+
pool: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
119
|
+
min: import("@sinclair/typebox").TNumber;
|
|
120
|
+
max: import("@sinclair/typebox").TNumber;
|
|
121
|
+
}>>;
|
|
82
122
|
}>>;
|
|
83
123
|
mssql: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
84
124
|
client: import("@sinclair/typebox").TString<string>;
|
|
85
|
-
connection: import("@sinclair/typebox").TString<string
|
|
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
|
+
pool: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
133
|
+
min: import("@sinclair/typebox").TNumber;
|
|
134
|
+
max: import("@sinclair/typebox").TNumber;
|
|
135
|
+
}>>;
|
|
86
136
|
}>>;
|
|
87
137
|
}>;
|
|
88
138
|
export type DefaultAppConfiguration = Static<typeof defaultAppConfiguration>;
|
package/lib/default-schemas.js
CHANGED
|
@@ -41,7 +41,20 @@ exports.authenticationSettingsSchema = typebox_1.Type.Object({
|
|
|
41
41
|
});
|
|
42
42
|
exports.sqlSettingsSchema = typebox_1.Type.Optional(typebox_1.Type.Object({
|
|
43
43
|
client: typebox_1.Type.String(),
|
|
44
|
-
connection: typebox_1.Type.
|
|
44
|
+
connection: typebox_1.Type.Union([
|
|
45
|
+
typebox_1.Type.String(),
|
|
46
|
+
typebox_1.Type.Partial(typebox_1.Type.Object({
|
|
47
|
+
host: typebox_1.Type.String(),
|
|
48
|
+
port: typebox_1.Type.Number(),
|
|
49
|
+
user: typebox_1.Type.String(),
|
|
50
|
+
password: typebox_1.Type.String(),
|
|
51
|
+
database: typebox_1.Type.String()
|
|
52
|
+
}))
|
|
53
|
+
]),
|
|
54
|
+
pool: typebox_1.Type.Optional(typebox_1.Type.Object({
|
|
55
|
+
min: typebox_1.Type.Number(),
|
|
56
|
+
max: typebox_1.Type.Number()
|
|
57
|
+
}))
|
|
45
58
|
}));
|
|
46
59
|
exports.defaultAppConfiguration = typebox_1.Type.Object({
|
|
47
60
|
authentication: typebox_1.Type.Optional(exports.authenticationSettingsSchema),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-schemas.js","sourceRoot":"","sources":["../src/default-schemas.ts"],"names":[],"mappings":";;;AAAA,+CAAgD;AAEnC,QAAA,4BAA4B,GAAG,cAAI,CAAC,MAAM,CAAC;IACtD,MAAM,EAAE,cAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,wBAAwB,EAAE,CAAC;IAC9D,MAAM,EAAE,cAAI,CAAC,QAAQ,CAAC,cAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,mDAAmD,EAAE,CAAC,CAAC;IACxG,QAAQ,EAAE,cAAI,CAAC,QAAQ,CAAC,cAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,mDAAmD,EAAE,CAAC,CAAC;IAC1G,OAAO,EAAE,cAAI,CAAC,QAAQ,CAAC,cAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC,CAAC;IACtF,cAAc,EAAE,cAAI,CAAC,KAAK,CAAC,cAAI,CAAC,MAAM,EAAE,EAAE;QACxC,WAAW,EAAE,sFAAsF;KACpG,CAAC;IACF,eAAe,EAAE,cAAI,CAAC,QAAQ,CAC5B,cAAI,CAAC,KAAK,CAAC,cAAI,CAAC,MAAM,EAAE,EAAE;QACxB,WAAW,EACT,sIAAsI;KACzI,CAAC,CACH;IACD,UA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AE,cAAI,CAAC,MAAM,EAAE;QACtB,GAAG,EAAE,cAAI,CAAC,MAAM,EAAE;KACnB,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAChC,CACF;IACD,OAAO,EAAE,cAAI,CAAC,QAAQ,CAAC,cAAI,CAAC,KAAK,CAAC,cAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACjD,OAAO,EAAE,cAAI,CAAC,QAAQ,CAAC,cAAI,CAAC,MAAM,EAAE,CAAC;IACrC,KAAK,EAAE,yBAAiB;IACxB,UAAU,EAAE,yBAAiB;IAC7B,MAAM,EAAE,yBAAiB;IACzB,KAAK,EAAE,yBAAiB;CACzB,EACD,EAAE,GAAG,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,KAAK,EAAE,CACjE,CAAA"}
|
package/lib/index.d.ts
CHANGED
|
@@ -44,9 +44,12 @@ export declare function sortDefinition<T extends TObject>(schema: T): TObject<T[
|
|
|
44
44
|
* including operators like `$gt`, `$lt` etc. for a single property
|
|
45
45
|
*
|
|
46
46
|
* @param def The property definition
|
|
47
|
+
* @param extension Additional properties to add to the property query
|
|
47
48
|
* @returns The Feathers query syntax schema
|
|
48
49
|
*/
|
|
49
|
-
export declare const queryProperty: <T extends TSchema
|
|
50
|
+
export declare const queryProperty: <T extends TSchema, X extends {
|
|
51
|
+
[key: string]: TSchema;
|
|
52
|
+
}>(def: T, extension?: X) => TOptional<import("@sinclair/typebox").TUnion<[T, import("@sinclair/typebox").TPartial<TIntersect<[TObject<{
|
|
50
53
|
$gt: T;
|
|
51
54
|
$gte: T;
|
|
52
55
|
$lt: T;
|
|
@@ -54,59 +57,65 @@ export declare const queryProperty: <T extends TSchema>(def: T) => TOptional<imp
|
|
|
54
57
|
$ne: T;
|
|
55
58
|
$in: import("@sinclair/typebox").TArray<T>;
|
|
56
59
|
$nin: import("@sinclair/typebox").TArray<T>;
|
|
57
|
-
}>>]>>;
|
|
60
|
+
}>, TObject<X>]>>]>>;
|
|
58
61
|
/**
|
|
59
62
|
* Creates a Feathers query syntax schema for the properties defined in `definition`.
|
|
60
63
|
*
|
|
61
64
|
* @param definition The properties to create the Feathers query syntax schema for
|
|
65
|
+
* @param extensions Additional properties to add to a property query
|
|
62
66
|
* @returns The Feathers query syntax schema
|
|
63
67
|
*/
|
|
64
|
-
export declare const queryProperties: <T extends TObject<import("@sinclair/typebox").TProperties
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
$
|
|
68
|
-
$
|
|
69
|
-
$
|
|
70
|
-
$
|
|
71
|
-
$
|
|
72
|
-
|
|
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]?: {
|
|
69
|
+
[key: string]: TSchema;
|
|
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<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>>;
|
|
73
79
|
/**
|
|
74
80
|
* Creates a TypeBox schema for the complete Feathers query syntax including `$limit`, $skip`, `$or`
|
|
75
81
|
* and `$sort` and `$select` for the allowed properties.
|
|
76
82
|
*
|
|
77
83
|
* @param type The properties to create the query syntax for
|
|
84
|
+
* @param extensions Additional properties to add to the query syntax
|
|
78
85
|
* @param options Options for the TypeBox object schema
|
|
79
86
|
* @returns A TypeBox object representing the complete Feathers query syntax for the given properties
|
|
80
87
|
*/
|
|
81
|
-
export declare const querySyntax: <T extends TObject<import("@sinclair/typebox").TProperties> | TIntersect<TObject<import("@sinclair/typebox").TProperties>[]
|
|
88
|
+
export declare const querySyntax: <T extends TObject<import("@sinclair/typebox").TProperties> | TIntersect<TObject<import("@sinclair/typebox").TProperties>[]>, X extends T["properties"] extends infer T_1 ? { [K in keyof T_1]?: {
|
|
89
|
+
[key: string]: TSchema;
|
|
90
|
+
}; } : never>(type: T, extensions?: X, options?: ObjectOptions) => TIntersect<[import("@sinclair/typebox").TPartial<TObject<{
|
|
82
91
|
$limit: import("@sinclair/typebox").TNumber;
|
|
83
92
|
$skip: import("@sinclair/typebox").TNumber;
|
|
84
|
-
$sort: TObject<T["properties"] extends infer
|
|
93
|
+
$sort: TObject<T["properties"] extends infer T_2 ? { [K_1 in keyof T_2]: TOptional<TInteger>; } : never>;
|
|
85
94
|
$select: import("@sinclair/typebox").TUnsafe<(keyof T["properties"])[]>;
|
|
86
|
-
$or: import("@sinclair/typebox").TArray<TOptional<TObject<T["properties"] extends infer
|
|
87
|
-
$gt: T["properties"][
|
|
88
|
-
$gte: T["properties"][
|
|
89
|
-
$lt: T["properties"][
|
|
90
|
-
$lte: T["properties"][
|
|
91
|
-
$ne: T["properties"][
|
|
92
|
-
$in: import("@sinclair/typebox").TArray<T["properties"][
|
|
93
|
-
$nin: import("@sinclair/typebox").TArray<T["properties"][
|
|
94
|
-
}>>]>>; } : never>>>;
|
|
95
|
-
$and: import("@sinclair/typebox").TArray<TOptional<TObject<T["properties"] extends infer
|
|
96
|
-
$gt: T["properties"][
|
|
97
|
-
$gte: T["properties"][
|
|
98
|
-
$lt: T["properties"][
|
|
99
|
-
$lte: T["properties"][
|
|
100
|
-
$ne: T["properties"][
|
|
101
|
-
$in: import("@sinclair/typebox").TArray<T["properties"][
|
|
102
|
-
$nin: import("@sinclair/typebox").TArray<T["properties"][
|
|
103
|
-
}>>]>>; } : never>>>;
|
|
104
|
-
}>>, TOptional<TObject<T["properties"] extends infer
|
|
105
|
-
$gt: T["properties"][
|
|
106
|
-
$gte: T["properties"][
|
|
107
|
-
$lt: T["properties"][
|
|
108
|
-
$lte: T["properties"][
|
|
109
|
-
$ne: T["properties"][
|
|
110
|
-
$in: import("@sinclair/typebox").TArray<T["properties"][
|
|
111
|
-
$nin: import("@sinclair/typebox").TArray<T["properties"][
|
|
112
|
-
}>>]>>; } : never>>]>;
|
|
95
|
+
$or: import("@sinclair/typebox").TArray<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<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>>>;
|
|
104
|
+
$and: import("@sinclair/typebox").TArray<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<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
|
+
}>>, 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<TIntersect<[TObject<{
|
|
114
|
+
$gt: T["properties"][K_2];
|
|
115
|
+
$gte: T["properties"][K_2];
|
|
116
|
+
$lt: T["properties"][K_2];
|
|
117
|
+
$lte: T["properties"][K_2];
|
|
118
|
+
$ne: T["properties"][K_2];
|
|
119
|
+
$in: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
120
|
+
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
121
|
+
}>, TObject<X[K_2]>]>>]>>; } : never>>]>;
|
package/lib/index.js
CHANGED
|
@@ -80,35 +80,40 @@ exports.sortDefinition = sortDefinition;
|
|
|
80
80
|
* including operators like `$gt`, `$lt` etc. for a single property
|
|
81
81
|
*
|
|
82
82
|
* @param def The property definition
|
|
83
|
+
* @param extension Additional properties to add to the property query
|
|
83
84
|
* @returns The Feathers query syntax schema
|
|
84
85
|
*/
|
|
85
|
-
const queryProperty = (def) => typebox_1.Type.Optional(typebox_1.Type.Union([
|
|
86
|
+
const queryProperty = (def, extension = {}) => typebox_1.Type.Optional(typebox_1.Type.Union([
|
|
86
87
|
def,
|
|
87
|
-
typebox_1.Type.Partial(typebox_1.Type.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
typebox_1.Type.Partial(typebox_1.Type.Intersect([
|
|
89
|
+
typebox_1.Type.Object({
|
|
90
|
+
$gt: def,
|
|
91
|
+
$gte: def,
|
|
92
|
+
$lt: def,
|
|
93
|
+
$lte: def,
|
|
94
|
+
$ne: def,
|
|
95
|
+
$in: typebox_1.Type.Array(def),
|
|
96
|
+
$nin: typebox_1.Type.Array(def)
|
|
97
|
+
}),
|
|
98
|
+
typebox_1.Type.Object(extension)
|
|
99
|
+
], { additionalProperties: false }))
|
|
96
100
|
]));
|
|
97
101
|
exports.queryProperty = queryProperty;
|
|
98
102
|
/**
|
|
99
103
|
* Creates a Feathers query syntax schema for the properties defined in `definition`.
|
|
100
104
|
*
|
|
101
105
|
* @param definition The properties to create the Feathers query syntax schema for
|
|
106
|
+
* @param extensions Additional properties to add to a property query
|
|
102
107
|
* @returns The Feathers query syntax schema
|
|
103
108
|
*/
|
|
104
|
-
const queryProperties = (definition) => {
|
|
109
|
+
const queryProperties = (definition, extensions = {}) => {
|
|
105
110
|
const properties = Object.keys(definition.properties).reduce((res, key) => {
|
|
106
111
|
const result = res;
|
|
107
112
|
const value = definition.properties[key];
|
|
108
|
-
if (value.$ref
|
|
109
|
-
throw new Error(`Can not create query syntax schema for property '${key}'
|
|
113
|
+
if (value.$ref) {
|
|
114
|
+
throw new Error(`Can not create query syntax schema for reference property '${key}'`);
|
|
110
115
|
}
|
|
111
|
-
result[key] = (0, exports.queryProperty)(value);
|
|
116
|
+
result[key] = (0, exports.queryProperty)(value, extensions[key]);
|
|
112
117
|
return result;
|
|
113
118
|
}, {});
|
|
114
119
|
return typebox_1.Type.Optional(typebox_1.Type.Object(properties, { additionalProperties: false }));
|
|
@@ -119,11 +124,12 @@ exports.queryProperties = queryProperties;
|
|
|
119
124
|
* and `$sort` and `$select` for the allowed properties.
|
|
120
125
|
*
|
|
121
126
|
* @param type The properties to create the query syntax for
|
|
127
|
+
* @param extensions Additional properties to add to the query syntax
|
|
122
128
|
* @param options Options for the TypeBox object schema
|
|
123
129
|
* @returns A TypeBox object representing the complete Feathers query syntax for the given properties
|
|
124
130
|
*/
|
|
125
|
-
const querySyntax = (type, options = { additionalProperties: false }) => {
|
|
126
|
-
const propertySchema = (0, exports.queryProperties)(type);
|
|
131
|
+
const querySyntax = (type, extensions = {}, options = { additionalProperties: false }) => {
|
|
132
|
+
const propertySchema = (0, exports.queryProperties)(type, extensions);
|
|
127
133
|
return typebox_1.Type.Intersect([
|
|
128
134
|
typebox_1.Type.Partial(typebox_1.Type.Object({
|
|
129
135
|
$limit: typebox_1.Type.Number({ minimum: 0 }),
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA0G;AAC1G,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+CAA0G;AAC1G,+CAAiF;AAEjF,oDAAiC;AACjC,oDAAiC;AAQjC;;;;;;GAMG;AACI,MAAM,YAAY,GAAG,CAAiB,MAAe,EAAE,SAAc,EAAmB,EAAE,CAC/F,mBAAU,CAAC,YAAY,CAAC,MAAa,EAAE,SAAS,CAAC,CAAA;AADtC,QAAA,YAAY,gBAC0B;AAEnD;;;;;;;;;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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1B,GAAG,EAAE,cAAI,CAAC,KAAK,CAAC,cAAc,CAAC;YAC/B,IAAI,EAAE,cAAI,CAAC,KAAK,CAAC,cAAc,CAAC;SACjC,EACD,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAChC,CACF;QACD,cAAc;KACf,EACD,OAAO,CACR,CAAA;AACH,CAAC,CAAA;AA7BY,QAAA,WAAW,eA6BvB"}
|
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.0-pre.
|
|
4
|
+
"version": "5.0.0-pre.36",
|
|
5
5
|
"homepage": "https://feathersjs.com",
|
|
6
6
|
"main": "lib/",
|
|
7
7
|
"types": "lib/",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
],
|
|
43
43
|
"scripts": {
|
|
44
44
|
"prepublish": "npm run compile",
|
|
45
|
-
"pack": "npm pack --pack-destination ../
|
|
45
|
+
"pack": "npm pack --pack-destination ../generators/test/build",
|
|
46
46
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
|
47
47
|
"mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts",
|
|
48
48
|
"test": "npm run compile && npm run mocha"
|
|
@@ -54,15 +54,15 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@feathersjs/schema": "^5.0.0-pre.
|
|
58
|
-
"@sinclair/typebox": "^0.25.
|
|
57
|
+
"@feathersjs/schema": "^5.0.0-pre.36",
|
|
58
|
+
"@sinclair/typebox": "^0.25.21"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/mocha": "^10.0.1",
|
|
62
|
-
"@types/node": "^18.11.
|
|
63
|
-
"mocha": "^10.
|
|
62
|
+
"@types/node": "^18.11.18",
|
|
63
|
+
"mocha": "^10.2.0",
|
|
64
64
|
"shx": "^0.3.4",
|
|
65
|
-
"typescript": "^4.9.
|
|
65
|
+
"typescript": "^4.9.4"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "9a107b463cc80d7f3c28553c908987e05b0b634a"
|
|
68
68
|
}
|
package/src/default-schemas.ts
CHANGED
|
@@ -58,7 +58,24 @@ export const authenticationSettingsSchema = Type.Object({
|
|
|
58
58
|
export const sqlSettingsSchema = Type.Optional(
|
|
59
59
|
Type.Object({
|
|
60
60
|
client: Type.String(),
|
|
61
|
-
connection: Type.
|
|
61
|
+
connection: Type.Union([
|
|
62
|
+
Type.String(),
|
|
63
|
+
Type.Partial(
|
|
64
|
+
Type.Object({
|
|
65
|
+
host: Type.String(),
|
|
66
|
+
port: Type.Number(),
|
|
67
|
+
user: Type.String(),
|
|
68
|
+
password: Type.String(),
|
|
69
|
+
database: Type.String()
|
|
70
|
+
})
|
|
71
|
+
)
|
|
72
|
+
]),
|
|
73
|
+
pool: Type.Optional(
|
|
74
|
+
Type.Object({
|
|
75
|
+
min: Type.Number(),
|
|
76
|
+
max: Type.Number()
|
|
77
|
+
})
|
|
78
|
+
)
|
|
62
79
|
})
|
|
63
80
|
)
|
|
64
81
|
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Type, TObject, TInteger, TOptional, TSchema, TIntersect, ObjectOptions } from '@sinclair/typebox'
|
|
2
|
-
import { jsonSchema, Validator, DataValidatorMap, Ajv
|
|
2
|
+
import { jsonSchema, Validator, DataValidatorMap, Ajv } from '@feathersjs/schema'
|
|
3
3
|
|
|
4
4
|
export * from '@sinclair/typebox'
|
|
5
5
|
export * from './default-schemas'
|
|
@@ -77,52 +77,66 @@ export function sortDefinition<T extends TObject>(schema: T) {
|
|
|
77
77
|
* including operators like `$gt`, `$lt` etc. for a single property
|
|
78
78
|
*
|
|
79
79
|
* @param def The property definition
|
|
80
|
+
* @param extension Additional properties to add to the property query
|
|
80
81
|
* @returns The Feathers query syntax schema
|
|
81
82
|
*/
|
|
82
|
-
export const queryProperty = <T extends TSchema
|
|
83
|
+
export const queryProperty = <T extends TSchema, X extends { [key: string]: TSchema }>(
|
|
84
|
+
def: T,
|
|
85
|
+
extension: X = {} as X
|
|
86
|
+
) =>
|
|
83
87
|
Type.Optional(
|
|
84
88
|
Type.Union([
|
|
85
89
|
def,
|
|
86
90
|
Type.Partial(
|
|
87
|
-
Type.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
Type.Intersect(
|
|
92
|
+
[
|
|
93
|
+
Type.Object({
|
|
94
|
+
$gt: def,
|
|
95
|
+
$gte: def,
|
|
96
|
+
$lt: def,
|
|
97
|
+
$lte: def,
|
|
98
|
+
$ne: def,
|
|
99
|
+
$in: Type.Array(def),
|
|
100
|
+
$nin: Type.Array(def)
|
|
101
|
+
}),
|
|
102
|
+
Type.Object(extension)
|
|
103
|
+
],
|
|
104
|
+
{ additionalProperties: false }
|
|
105
|
+
)
|
|
97
106
|
)
|
|
98
107
|
])
|
|
99
108
|
)
|
|
100
109
|
|
|
101
|
-
type QueryProperty<T extends TSchema> = ReturnType<
|
|
110
|
+
type QueryProperty<T extends TSchema, X extends { [key: string]: TSchema }> = ReturnType<
|
|
111
|
+
typeof queryProperty<T, X>
|
|
112
|
+
>
|
|
102
113
|
|
|
103
114
|
/**
|
|
104
115
|
* Creates a Feathers query syntax schema for the properties defined in `definition`.
|
|
105
116
|
*
|
|
106
117
|
* @param definition The properties to create the Feathers query syntax schema for
|
|
118
|
+
* @param extensions Additional properties to add to a property query
|
|
107
119
|
* @returns The Feathers query syntax schema
|
|
108
120
|
*/
|
|
109
|
-
export const queryProperties = <
|
|
121
|
+
export const queryProperties = <
|
|
122
|
+
T extends TObject,
|
|
123
|
+
X extends { [K in keyof T['properties']]?: { [key: string]: TSchema } }
|
|
124
|
+
>(
|
|
125
|
+
definition: T,
|
|
126
|
+
extensions: X = {} as X
|
|
127
|
+
) => {
|
|
110
128
|
const properties = Object.keys(definition.properties).reduce((res, key) => {
|
|
111
129
|
const result = res as any
|
|
112
130
|
const value = definition.properties[key]
|
|
113
131
|
|
|
114
|
-
if (value.$ref
|
|
115
|
-
throw new Error(
|
|
116
|
-
`Can not create query syntax schema for property '${key}'. Only types ${SUPPORTED_TYPES.join(
|
|
117
|
-
', '
|
|
118
|
-
)} are allowed.`
|
|
119
|
-
)
|
|
132
|
+
if (value.$ref) {
|
|
133
|
+
throw new Error(`Can not create query syntax schema for reference property '${key}'`)
|
|
120
134
|
}
|
|
121
135
|
|
|
122
|
-
result[key] = queryProperty(value)
|
|
136
|
+
result[key] = queryProperty(value, extensions[key])
|
|
123
137
|
|
|
124
138
|
return result
|
|
125
|
-
}, {} as { [K in keyof T['properties']]: QueryProperty<T['properties'][K]> })
|
|
139
|
+
}, {} as { [K in keyof T['properties']]: QueryProperty<T['properties'][K], X[K]> })
|
|
126
140
|
|
|
127
141
|
return Type.Optional(Type.Object(properties, { additionalProperties: false }))
|
|
128
142
|
}
|
|
@@ -132,14 +146,19 @@ export const queryProperties = <T extends TObject>(definition: T) => {
|
|
|
132
146
|
* and `$sort` and `$select` for the allowed properties.
|
|
133
147
|
*
|
|
134
148
|
* @param type The properties to create the query syntax for
|
|
149
|
+
* @param extensions Additional properties to add to the query syntax
|
|
135
150
|
* @param options Options for the TypeBox object schema
|
|
136
151
|
* @returns A TypeBox object representing the complete Feathers query syntax for the given properties
|
|
137
152
|
*/
|
|
138
|
-
export const querySyntax = <
|
|
153
|
+
export const querySyntax = <
|
|
154
|
+
T extends TObject | TIntersect,
|
|
155
|
+
X extends { [K in keyof T['properties']]?: { [key: string]: TSchema } }
|
|
156
|
+
>(
|
|
139
157
|
type: T,
|
|
158
|
+
extensions: X = {} as X,
|
|
140
159
|
options: ObjectOptions = { additionalProperties: false }
|
|
141
160
|
) => {
|
|
142
|
-
const propertySchema = queryProperties(type)
|
|
161
|
+
const propertySchema = queryProperties(type, extensions)
|
|
143
162
|
|
|
144
163
|
return Type.Intersect(
|
|
145
164
|
[
|