@tsed/schema 8.17.2 → 8.18.0
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/functional-api-typing-plan.md +207 -0
- package/lib/esm/decorators/common/schema.js +2 -2
- package/lib/esm/domain/JsonSchema.js +105 -91
- package/lib/esm/domain/types.js +1 -0
- package/lib/esm/fn/allOf.js +2 -0
- package/lib/esm/fn/any.js +0 -5
- package/lib/esm/fn/anyOf.js +2 -1
- package/lib/esm/fn/boolean.js +3 -1
- package/lib/esm/fn/collection.js +13 -45
- package/lib/esm/fn/date.js +6 -0
- package/lib/esm/fn/email.js +2 -0
- package/lib/esm/fn/enums.js +2 -2
- package/lib/esm/fn/from.js +0 -11
- package/lib/esm/fn/index.js +10 -1
- package/lib/esm/fn/integer.js +2 -2
- package/lib/esm/fn/lazyRef.js +0 -3
- package/lib/esm/fn/number.js +2 -0
- package/lib/esm/fn/object.js +2 -1
- package/lib/esm/fn/string.js +2 -0
- package/lib/esm/fn/url.js +2 -0
- package/lib/esm/index.js +1 -0
- package/lib/types/decorators/common/default.d.ts +2 -2
- package/lib/types/decorators/common/schema.d.ts +3 -3
- package/lib/types/domain/JsonLazyRef.d.ts +1 -1
- package/lib/types/domain/JsonMedia.d.ts +1 -1
- package/lib/types/domain/JsonParameter.d.ts +1 -1
- package/lib/types/domain/JsonParameterStore.d.ts +1 -1
- package/lib/types/domain/JsonSchema.d.ts +58 -31
- package/lib/types/domain/types.d.ts +7 -0
- package/lib/types/fn/allOf.d.ts +5 -2
- package/lib/types/fn/any.d.ts +7 -1
- package/lib/types/fn/anyOf.d.ts +5 -3
- package/lib/types/fn/boolean.d.ts +4 -3
- package/lib/types/fn/collection.d.ts +33 -20
- package/lib/types/fn/date.d.ts +9 -4
- package/lib/types/fn/email.d.ts +3 -2
- package/lib/types/fn/enums.d.ts +11 -1
- package/lib/types/fn/from.d.ts +3 -1
- package/lib/types/fn/index.d.ts +14 -1
- package/lib/types/fn/integer.d.ts +3 -4
- package/lib/types/fn/lazyRef.d.ts +4 -2
- package/lib/types/fn/number.d.ts +3 -1
- package/lib/types/fn/object.d.ts +3 -4
- package/lib/types/fn/oneOf.d.ts +3 -2
- package/lib/types/fn/string.d.ts +3 -2
- package/lib/types/fn/uri.d.ts +1 -2
- package/lib/types/fn/url.d.ts +3 -2
- package/lib/types/index.d.ts +1 -0
- package/lib/types/registries/enumRegistries.d.ts +1 -1
- package/package.json +7 -7
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { JsonSchema } from "../domain/JsonSchema.js";
|
|
2
1
|
/**
|
|
3
2
|
* Declare a new boolean model.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
4
|
+
* See @@JsonSchema@@ to discover available methods.
|
|
5
|
+
*
|
|
6
|
+
* @schemaFunctional
|
|
6
7
|
*/
|
|
7
|
-
export declare function boolean(): JsonSchema
|
|
8
|
+
export declare function boolean(): import("../index.js").JsonSchema<boolean>;
|
|
@@ -1,43 +1,56 @@
|
|
|
1
1
|
import type { JsonSchema } from "../domain/JsonSchema.js";
|
|
2
2
|
/**
|
|
3
|
-
* Declare a new
|
|
3
|
+
* Declare a new array model. If an item schema is provided, it will be set as `items` and its type will be inferred.
|
|
4
4
|
*
|
|
5
5
|
* ```json
|
|
6
|
-
* {
|
|
7
|
-
* "type": "array"
|
|
8
|
-
* }
|
|
6
|
+
* { "type": "array" }
|
|
9
7
|
* ```
|
|
10
8
|
*
|
|
11
|
-
*
|
|
9
|
+
* See @@JsonSchema@@ to discover available methods.
|
|
12
10
|
*
|
|
13
11
|
* @schemaFunctional
|
|
14
12
|
*/
|
|
15
|
-
export declare function array(): JsonSchema
|
|
13
|
+
export declare function array(): JsonSchema<any[]>;
|
|
14
|
+
export declare function array<I>(item: JsonSchema<I>): JsonSchema<I[]>;
|
|
16
15
|
/**
|
|
17
|
-
* Declare a new object model with `additionalProperties: true
|
|
16
|
+
* Declare a new object model with `additionalProperties: true` (map-like). If a value schema is provided, it is used
|
|
17
|
+
* as `additionalProperties` and its type will be inferred.
|
|
18
18
|
*
|
|
19
19
|
* ```json
|
|
20
|
-
* {
|
|
21
|
-
* "type": "object",
|
|
22
|
-
* "additionalProperties": true
|
|
23
|
-
* }
|
|
20
|
+
* { "type": "object", "additionalProperties": true }
|
|
24
21
|
* ```
|
|
25
22
|
*
|
|
26
|
-
*
|
|
23
|
+
* See @@JsonSchema@@ to discover available methods.
|
|
27
24
|
*
|
|
28
25
|
* @schemaFunctional
|
|
29
26
|
*/
|
|
30
|
-
export declare function map(): JsonSchema
|
|
27
|
+
export declare function map(): JsonSchema<Record<string, any>>;
|
|
28
|
+
export declare function map<V>(value: JsonSchema<V>): JsonSchema<Map<string, V>>;
|
|
31
29
|
/**
|
|
32
|
-
* Declare a new array model with `uniqueItems: true`.
|
|
30
|
+
* Declare a new array model representing a Set with `uniqueItems: true`. If an item schema is provided, it will be set
|
|
31
|
+
* as `items` and its type will be inferred as `Set<I>`.
|
|
33
32
|
*
|
|
34
33
|
* ```json
|
|
35
|
-
* {
|
|
36
|
-
* "type": "array",
|
|
37
|
-
* "uniqueItems": true
|
|
38
|
-
* }
|
|
34
|
+
* { "type": "array", "uniqueItems": true }
|
|
39
35
|
* ```
|
|
40
36
|
*
|
|
41
|
-
*
|
|
37
|
+
* See @@JsonSchema@@ to discover available methods.
|
|
38
|
+
*
|
|
39
|
+
* @schemaFunctional
|
|
40
|
+
*/
|
|
41
|
+
export declare function set(): JsonSchema<Set<any>>;
|
|
42
|
+
export declare function set<I>(item: JsonSchema<I>): JsonSchema<Set<I>>;
|
|
43
|
+
/**
|
|
44
|
+
* Declare a new object model with `additionalProperties: true` (record-like). If a value schema is provided, it is used
|
|
45
|
+
* as `additionalProperties` and its type will be inferred as `Record<string, V>`.
|
|
46
|
+
*
|
|
47
|
+
* ```json
|
|
48
|
+
* { "type": "object", "additionalProperties": true }
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* See @@JsonSchema@@ to discover available methods.
|
|
52
|
+
*
|
|
53
|
+
* @schemaFunctional
|
|
42
54
|
*/
|
|
43
|
-
export declare function
|
|
55
|
+
export declare function record<K extends string | number | symbol = string, V = any>(): JsonSchema<Record<K, V>>;
|
|
56
|
+
export declare function record<V>(value: JsonSchema<V>): JsonSchema<Record<string, V>>;
|
package/lib/types/fn/date.d.ts
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import type { JsonSchema } from "../domain/JsonSchema.js";
|
|
2
1
|
/**
|
|
3
2
|
* Declare a new string model with `format: date`.
|
|
4
3
|
*
|
|
5
4
|
* See @@JsonSchema@@ to discover available methods.
|
|
5
|
+
*
|
|
6
|
+
* @schemaFunctional
|
|
6
7
|
*/
|
|
7
|
-
export declare function date(): JsonSchema
|
|
8
|
+
export declare function date(): import("../index.js").JsonSchema<Date>;
|
|
8
9
|
/**
|
|
9
10
|
* Declare a new string model with `format: datetime`.
|
|
10
11
|
*
|
|
11
12
|
* See @@JsonSchema@@ to discover available methods.
|
|
13
|
+
*
|
|
14
|
+
* @schemaFunctional
|
|
12
15
|
*/
|
|
13
|
-
export declare function datetime(): JsonSchema
|
|
16
|
+
export declare function datetime(): import("../index.js").JsonSchema<Date>;
|
|
14
17
|
/**
|
|
15
18
|
* Declare a new string model with `format: time`.
|
|
16
19
|
*
|
|
17
20
|
* See @@JsonSchema@@ to discover available methods.
|
|
21
|
+
*
|
|
22
|
+
* @schemaFunctional
|
|
18
23
|
*/
|
|
19
|
-
export declare function time(): JsonSchema
|
|
24
|
+
export declare function time(): import("../index.js").JsonSchema<Date>;
|
package/lib/types/fn/email.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { JsonSchema } from "../domain/JsonSchema.js";
|
|
2
1
|
/**
|
|
3
2
|
* Declare a new string model with `format: email`.
|
|
4
3
|
*
|
|
@@ -10,5 +9,7 @@ import type { JsonSchema } from "../domain/JsonSchema.js";
|
|
|
10
9
|
* const schema = email();
|
|
11
10
|
* // Results in: { type: "string", format: "email" }
|
|
12
11
|
* ```
|
|
12
|
+
*
|
|
13
|
+
* @schemaFunctional
|
|
13
14
|
*/
|
|
14
|
-
export declare function email(): JsonSchema
|
|
15
|
+
export declare function email(): import("../index.js").JsonSchema<string>;
|
package/lib/types/fn/enums.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import type { JsonSchema } from "../domain/JsonSchema.js";
|
|
2
|
+
/**
|
|
3
|
+
* Declare a new enum model.
|
|
4
|
+
*
|
|
5
|
+
* See @@JsonSchema@@ to discover available methods.
|
|
6
|
+
*
|
|
7
|
+
* @schemaFunctional
|
|
8
|
+
* @param e
|
|
9
|
+
*/
|
|
10
|
+
export declare function enums<E extends Record<string, string | number>>(e: E): JsonSchema<E[keyof E]>;
|
|
11
|
+
export declare function enums<T extends readonly (string | number)[]>(e: T): JsonSchema<T[number]>;
|
package/lib/types/fn/from.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
2
|
import { JsonSchema } from "../domain/JsonSchema.js";
|
|
3
|
+
import type { CtorToType } from "../domain/types.js";
|
|
3
4
|
/**
|
|
4
5
|
* Create a new model from the given type.
|
|
5
6
|
*
|
|
@@ -11,4 +12,5 @@ import { JsonSchema } from "../domain/JsonSchema.js";
|
|
|
11
12
|
*
|
|
12
13
|
* @schemaFunctional
|
|
13
14
|
*/
|
|
14
|
-
export declare function from
|
|
15
|
+
export declare function from<TC extends Type<any> = Type<any>>(): JsonSchema<CtorToType<ObjectConstructor>>;
|
|
16
|
+
export declare function from<TC extends Type<any> = Type<any>>(type?: TC): JsonSchema<CtorToType<TC>>;
|
package/lib/types/fn/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import type { Infer } from "../domain/types.js";
|
|
1
2
|
import { allOf } from "./allOf.js";
|
|
3
|
+
import { any } from "./any.js";
|
|
2
4
|
import { anyOf } from "./anyOf.js";
|
|
3
5
|
import { boolean } from "./boolean.js";
|
|
4
|
-
import { array, map, set } from "./collection.js";
|
|
6
|
+
import { array, map, record, set } from "./collection.js";
|
|
5
7
|
import { date, datetime, time } from "./date.js";
|
|
6
8
|
import { email } from "./email.js";
|
|
7
9
|
import { enums } from "./enums.js";
|
|
10
|
+
import { from } from "./from.js";
|
|
8
11
|
import { integer } from "./integer.js";
|
|
9
12
|
import { lazyRef } from "./lazyRef.js";
|
|
10
13
|
import { number } from "./number.js";
|
|
@@ -13,13 +16,20 @@ import { oneOf } from "./oneOf.js";
|
|
|
13
16
|
import { string } from "./string.js";
|
|
14
17
|
import { uri } from "./uri.js";
|
|
15
18
|
import { url } from "./url.js";
|
|
19
|
+
/**
|
|
20
|
+
* A namespace of all schema builder functions.
|
|
21
|
+
* @schemaFunctional
|
|
22
|
+
*/
|
|
16
23
|
export declare const s: {
|
|
24
|
+
readonly from: typeof from;
|
|
17
25
|
readonly allOf: typeof allOf;
|
|
18
26
|
readonly anyOf: typeof anyOf;
|
|
27
|
+
readonly any: typeof any;
|
|
19
28
|
readonly boolean: typeof boolean;
|
|
20
29
|
readonly array: typeof array;
|
|
21
30
|
readonly map: typeof map;
|
|
22
31
|
readonly set: typeof set;
|
|
32
|
+
readonly record: typeof record;
|
|
23
33
|
readonly date: typeof date;
|
|
24
34
|
readonly datetime: typeof datetime;
|
|
25
35
|
readonly time: typeof time;
|
|
@@ -34,3 +44,6 @@ export declare const s: {
|
|
|
34
44
|
readonly uri: typeof uri;
|
|
35
45
|
readonly url: typeof url;
|
|
36
46
|
};
|
|
47
|
+
export declare namespace s {
|
|
48
|
+
type infer<S> = Infer<S>;
|
|
49
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { JsonSchema } from "../domain/JsonSchema.js";
|
|
2
1
|
/**
|
|
3
2
|
* Declare a new integer model.
|
|
4
3
|
*
|
|
5
4
|
* See @@JsonSchema@@ to discover available methods.
|
|
6
5
|
*
|
|
7
|
-
* @returns
|
|
8
|
-
* @
|
|
6
|
+
* @returns A schema configured for integer values
|
|
7
|
+
* @schemaFunctional
|
|
9
8
|
*/
|
|
10
|
-
export declare function integer(): JsonSchema
|
|
9
|
+
export declare function integer(): import("../index.js").JsonSchema<number>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { JsonSchema } from "../domain/JsonSchema.js";
|
|
2
2
|
/**
|
|
3
3
|
* Declare a sub schema which will be resolved later. Use this function when you have a circular reference between two schemes.
|
|
4
|
+
*
|
|
5
|
+
* @schemaFunctional
|
|
4
6
|
*/
|
|
5
|
-
export declare function lazyRef(
|
|
7
|
+
export declare function lazyRef<T extends abstract new (...args: any) => any>(cb: () => T): JsonSchema<InstanceType<T>>;
|
package/lib/types/fn/number.d.ts
CHANGED
|
@@ -2,5 +2,7 @@
|
|
|
2
2
|
* Declare a new number model.
|
|
3
3
|
*
|
|
4
4
|
* * See @@JsonSchema@@ to discover available methods.
|
|
5
|
+
*
|
|
6
|
+
* @schemaFunctional
|
|
5
7
|
*/
|
|
6
|
-
export declare function number(): import("../index.js").JsonSchema
|
|
8
|
+
export declare function number(): import("../index.js").JsonSchema<number>;
|
package/lib/types/fn/object.d.ts
CHANGED
|
@@ -14,8 +14,7 @@ import { JsonSchema } from "../domain/JsonSchema.js";
|
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
16
|
* @param properties - An object containing property definitions where each value is a JsonSchema
|
|
17
|
-
* @returns
|
|
17
|
+
* @returns A new object model with the specified properties
|
|
18
|
+
* @schemaFunctional
|
|
18
19
|
*/
|
|
19
|
-
export declare function object(properties?:
|
|
20
|
-
[key: string]: JsonSchema;
|
|
21
|
-
}): JsonSchema;
|
|
20
|
+
export declare function object<P extends Record<string, JsonSchema<any>> = Record<string, JsonSchema<any>>>(properties?: P): JsonSchema<import("../index.js").PropsToShape<P>>;
|
package/lib/types/fn/oneOf.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { JsonSchema } from "../domain/JsonSchema.js";
|
|
1
|
+
import type { AnyJsonSchema, JsonSchema } from "../domain/JsonSchema.js";
|
|
2
|
+
import type { Infer } from "../domain/types.js";
|
|
2
3
|
/**
|
|
3
4
|
* See https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.28
|
|
4
5
|
*
|
|
@@ -7,4 +8,4 @@ import type { JsonSchema } from "../domain/JsonSchema.js";
|
|
|
7
8
|
* @schemaFunctional
|
|
8
9
|
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.28
|
|
9
10
|
*/
|
|
10
|
-
export declare function oneOf(...oneOf:
|
|
11
|
+
export declare function oneOf<S extends Array<AnyJsonSchema | null>>(...oneOf: S): JsonSchema<Infer<S[number]>>;
|
package/lib/types/fn/string.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { JsonSchema } from "../domain/JsonSchema.js";
|
|
2
1
|
/**
|
|
3
2
|
* Declare a new string model.
|
|
4
3
|
*
|
|
5
4
|
* See @@JsonSchema@@ to discover available methods.
|
|
5
|
+
*
|
|
6
|
+
* @schemaFunctional
|
|
6
7
|
*/
|
|
7
|
-
export declare function string(): JsonSchema
|
|
8
|
+
export declare function string(): import("../index.js").JsonSchema<string>;
|
package/lib/types/fn/uri.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { JsonSchema } from "../domain/JsonSchema.js";
|
|
2
1
|
/**
|
|
3
2
|
* Declare a new string model with `format: uri`.
|
|
4
3
|
*
|
|
@@ -6,4 +5,4 @@ import type { JsonSchema } from "../domain/JsonSchema.js";
|
|
|
6
5
|
*
|
|
7
6
|
* @schemaFunctional
|
|
8
7
|
*/
|
|
9
|
-
export declare function uri(): JsonSchema
|
|
8
|
+
export declare function uri(): import("../index.js").JsonSchema<string>;
|
package/lib/types/fn/url.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { JsonSchema } from "../domain/JsonSchema.js";
|
|
2
1
|
/**
|
|
3
2
|
* Declare a new string model with `format: url`.
|
|
4
3
|
*
|
|
5
4
|
* See @@JsonSchema@@ to discover available methods.
|
|
5
|
+
*
|
|
6
|
+
* @schemaFunctional
|
|
6
7
|
*/
|
|
7
|
-
export declare function url(): JsonSchema
|
|
8
|
+
export declare function url(): import("../index.js").JsonSchema<string>;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -134,6 +134,7 @@ export * from "./domain/JsonRequestBody.js";
|
|
|
134
134
|
export * from "./domain/JsonResponse.js";
|
|
135
135
|
export * from "./domain/JsonSchema.js";
|
|
136
136
|
export * from "./domain/SpecTypes.js";
|
|
137
|
+
export * from "./domain/types.js";
|
|
137
138
|
export * from "./fn/allOf.js";
|
|
138
139
|
export * from "./fn/any.js";
|
|
139
140
|
export * from "./fn/anyOf.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { JsonSchema } from "../domain/JsonSchema.js";
|
|
2
|
-
export declare const enumsRegistry: Map<any, JsonSchema
|
|
2
|
+
export declare const enumsRegistry: Map<any, JsonSchema<import("json-schema").JSONSchema7Type>>;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tsed/schema",
|
|
3
3
|
"description": "JsonSchema module for Ts.ED Framework",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "8.
|
|
5
|
+
"version": "8.18.0",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"tsed"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@tsed/openspec": "8.
|
|
37
|
+
"@tsed/openspec": "8.18.0",
|
|
38
38
|
"change-case": "^5.4.4",
|
|
39
39
|
"json-schema": "0.4.0",
|
|
40
40
|
"picomatch": "4.0.2",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@apidevtools/swagger-parser": "10.1.0",
|
|
46
|
-
"@tsed/barrels": "8.
|
|
47
|
-
"@tsed/core": "8.
|
|
48
|
-
"@tsed/hooks": "8.
|
|
49
|
-
"@tsed/openspec": "8.
|
|
50
|
-
"@tsed/typescript": "8.
|
|
46
|
+
"@tsed/barrels": "8.18.0",
|
|
47
|
+
"@tsed/core": "8.18.0",
|
|
48
|
+
"@tsed/hooks": "8.18.0",
|
|
49
|
+
"@tsed/openspec": "8.18.0",
|
|
50
|
+
"@tsed/typescript": "8.18.0",
|
|
51
51
|
"@types/fs-extra": "11.0.4",
|
|
52
52
|
"@types/json-schema": "7.0.15",
|
|
53
53
|
"@types/picomatch": "3.0.2",
|