@feathersjs/typebox 5.0.0-pre.36 → 5.0.0-pre.38
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 +12 -0
- package/lib/index.d.ts +14 -3
- package/lib/index.js +7 -6
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.38](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.37...v5.0.0-pre.38) (2023-02-17)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **schema:** Add schema helper for handling Object ids ([#3058](https://github.com/feathersjs/feathers/issues/3058)) ([1393bed](https://github.com/feathersjs/feathers/commit/1393bed81a9ee814de6aab0e537af83e667591a2))
|
|
11
|
+
|
|
12
|
+
# [5.0.0-pre.37](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.36...v5.0.0-pre.37) (2023-02-09)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- **typebox:** Allow nested or in and queries ([#3029](https://github.com/feathersjs/feathers/issues/3029)) ([39e0b78](https://github.com/feathersjs/feathers/commit/39e0b785238b809aa9b4dea9b95efc3c188c9baa))
|
|
17
|
+
|
|
6
18
|
# [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
19
|
|
|
8
20
|
### Bug Fixes
|
package/lib/index.d.ts
CHANGED
|
@@ -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<T["properties"] extends infer T_2 ? { [K_1 in keyof T_2]: TOptional<TInteger>; } : never>;
|
|
94
94
|
$select: import("@sinclair/typebox").TUnsafe<(keyof T["properties"])[]>;
|
|
95
|
-
$
|
|
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<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,18 @@ 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]>]>>]>>; } : never
|
|
104
|
-
|
|
103
|
+
}>, TObject<X[K_2]>]>>]>>; } : never>>, TObject<{
|
|
104
|
+
$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<{
|
|
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_3 ? { [K_2 in keyof T_3]: TOptional<import("@sinclair/typebox").TUnion<[T["properties"][K_2], import("@sinclair/typebox").TPartial<TIntersect<[TObject<{
|
|
105
115
|
$gt: T["properties"][K_2];
|
|
106
116
|
$gte: T["properties"][K_2];
|
|
107
117
|
$lt: T["properties"][K_2];
|
|
@@ -119,3 +129,4 @@ export declare const querySyntax: <T extends TObject<import("@sinclair/typebox")
|
|
|
119
129
|
$in: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
120
130
|
$nin: import("@sinclair/typebox").TArray<T["properties"][K_2]>;
|
|
121
131
|
}>, TObject<X[K_2]>]>>]>>; } : never>>]>;
|
|
132
|
+
export declare const ObjectIdSchema: () => import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString<string>, TObject<{}>]>;
|
package/lib/index.js
CHANGED
|
@@ -14,7 +14,7 @@ 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.querySyntax = exports.queryProperties = exports.queryProperty = exports.sortDefinition = exports.StringEnum = exports.getDataValidator = exports.getValidator = void 0;
|
|
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);
|
|
@@ -110,9 +110,6 @@ const queryProperties = (definition, extensions = {}) => {
|
|
|
110
110
|
const properties = Object.keys(definition.properties).reduce((res, key) => {
|
|
111
111
|
const result = res;
|
|
112
112
|
const value = definition.properties[key];
|
|
113
|
-
if (value.$ref) {
|
|
114
|
-
throw new Error(`Can not create query syntax schema for reference property '${key}'`);
|
|
115
|
-
}
|
|
116
113
|
result[key] = (0, exports.queryProperty)(value, extensions[key]);
|
|
117
114
|
return result;
|
|
118
115
|
}, {});
|
|
@@ -130,17 +127,21 @@ exports.queryProperties = queryProperties;
|
|
|
130
127
|
*/
|
|
131
128
|
const querySyntax = (type, extensions = {}, options = { additionalProperties: false }) => {
|
|
132
129
|
const propertySchema = (0, exports.queryProperties)(type, extensions);
|
|
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 })]));
|
|
133
132
|
return typebox_1.Type.Intersect([
|
|
134
133
|
typebox_1.Type.Partial(typebox_1.Type.Object({
|
|
135
134
|
$limit: typebox_1.Type.Number({ minimum: 0 }),
|
|
136
135
|
$skip: typebox_1.Type.Number({ minimum: 0 }),
|
|
137
136
|
$sort: sortDefinition(type),
|
|
138
137
|
$select: arrayOfKeys(type),
|
|
139
|
-
$
|
|
140
|
-
$
|
|
138
|
+
$and,
|
|
139
|
+
$or
|
|
141
140
|
}, { additionalProperties: false })),
|
|
142
141
|
propertySchema
|
|
143
142
|
], options);
|
|
144
143
|
};
|
|
145
144
|
exports.querySyntax = querySyntax;
|
|
145
|
+
const ObjectIdSchema = () => typebox_1.Type.Union([typebox_1.Type.String({ objectid: true }), typebox_1.Type.Object({}, { additionalProperties: false })]);
|
|
146
|
+
exports.ObjectIdSchema = ObjectIdSchema;
|
|
146
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,+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,E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M,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.0-pre.
|
|
4
|
+
"version": "5.0.0-pre.38",
|
|
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.0-pre.
|
|
57
|
+
"@feathersjs/schema": "^5.0.0-pre.38",
|
|
58
58
|
"@sinclair/typebox": "^0.25.21"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/mocha": "^10.0.1",
|
|
62
|
-
"@types/node": "^18.
|
|
62
|
+
"@types/node": "^18.13.0",
|
|
63
63
|
"mocha": "^10.2.0",
|
|
64
64
|
"shx": "^0.3.4",
|
|
65
|
-
"typescript": "^4.9.
|
|
65
|
+
"typescript": "^4.9.5"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "7fc86307438ae8cf3f71ce3b677be8bcc55768c1"
|
|
68
68
|
}
|
package/src/index.ts
CHANGED
|
@@ -129,10 +129,6 @@ export const queryProperties = <
|
|
|
129
129
|
const result = res as any
|
|
130
130
|
const value = definition.properties[key]
|
|
131
131
|
|
|
132
|
-
if (value.$ref) {
|
|
133
|
-
throw new Error(`Can not create query syntax schema for reference property '${key}'`)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
132
|
result[key] = queryProperty(value, extensions[key])
|
|
137
133
|
|
|
138
134
|
return result
|
|
@@ -159,6 +155,8 @@ export const querySyntax = <
|
|
|
159
155
|
options: ObjectOptions = { additionalProperties: false }
|
|
160
156
|
) => {
|
|
161
157
|
const propertySchema = queryProperties(type, extensions)
|
|
158
|
+
const $or = Type.Array(propertySchema)
|
|
159
|
+
const $and = Type.Array(Type.Union([propertySchema, Type.Object({ $or })]))
|
|
162
160
|
|
|
163
161
|
return Type.Intersect(
|
|
164
162
|
[
|
|
@@ -169,8 +167,8 @@ export const querySyntax = <
|
|
|
169
167
|
$skip: Type.Number({ minimum: 0 }),
|
|
170
168
|
$sort: sortDefinition(type),
|
|
171
169
|
$select: arrayOfKeys(type),
|
|
172
|
-
$
|
|
173
|
-
$
|
|
170
|
+
$and,
|
|
171
|
+
$or
|
|
174
172
|
},
|
|
175
173
|
{ additionalProperties: false }
|
|
176
174
|
)
|
|
@@ -180,3 +178,6 @@ export const querySyntax = <
|
|
|
180
178
|
options
|
|
181
179
|
)
|
|
182
180
|
}
|
|
181
|
+
|
|
182
|
+
export const ObjectIdSchema = () =>
|
|
183
|
+
Type.Union([Type.String({ objectid: true }), Type.Object({}, { additionalProperties: false })])
|