@tsed/schema 8.4.4 → 8.4.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.
Files changed (36) hide show
  1. package/lib/browser/schema.umd.min.js.map +1 -1
  2. package/lib/esm/decorators/operations/operationPath.js +1 -1
  3. package/lib/esm/decorators/operations/tags.js +10 -1
  4. package/lib/esm/decorators/operations/tags.js.map +1 -1
  5. package/lib/types/decorators/generics/generics.d.ts +1 -1
  6. package/lib/types/decorators/operations/acceptMime.d.ts +1 -1
  7. package/lib/types/decorators/operations/consumes.d.ts +1 -1
  8. package/lib/types/decorators/operations/header.d.ts +1 -1
  9. package/lib/types/decorators/operations/operationId.d.ts +1 -1
  10. package/lib/types/decorators/operations/operationPath.d.ts +1 -1
  11. package/lib/types/decorators/operations/path.d.ts +1 -1
  12. package/lib/types/decorators/operations/produces.d.ts +1 -1
  13. package/lib/types/decorators/operations/redirect.d.ts +2 -2
  14. package/lib/types/decorators/operations/security.d.ts +2 -2
  15. package/lib/types/decorators/operations/summary.d.ts +1 -1
  16. package/lib/types/decorators/operations/tags.d.ts +11 -2
  17. package/package.json +10 -10
  18. package/src/decorators/generics/generics.ts +1 -1
  19. package/src/decorators/operations/acceptMime.ts +1 -1
  20. package/src/decorators/operations/consumes.spec.ts +1 -0
  21. package/src/decorators/operations/consumes.ts +1 -1
  22. package/src/decorators/operations/header.ts +1 -1
  23. package/src/decorators/operations/operationId.spec.ts +1 -0
  24. package/src/decorators/operations/operationId.ts +1 -1
  25. package/src/decorators/operations/operationPath.ts +1 -1
  26. package/src/decorators/operations/path.spec.ts +1 -0
  27. package/src/decorators/operations/path.ts +1 -1
  28. package/src/decorators/operations/produces.spec.ts +1 -0
  29. package/src/decorators/operations/produces.ts +1 -1
  30. package/src/decorators/operations/redirect.ts +3 -3
  31. package/src/decorators/operations/security.spec.ts +1 -0
  32. package/src/decorators/operations/security.ts +3 -3
  33. package/src/decorators/operations/summary.spec.ts +1 -0
  34. package/src/decorators/operations/summary.ts +1 -1
  35. package/src/decorators/operations/tags.spec.ts +1 -0
  36. package/src/decorators/operations/tags.ts +11 -2
@@ -6,7 +6,7 @@ import { JsonEntityFn } from "../common/jsonEntityFn.js";
6
6
  * ::: warning
7
7
  * Don't use decorator with Ts.ED application.
8
8
  *
9
- * Use theses decorators instead:
9
+ * Use these decorators instead:
10
10
  *
11
11
  * <ApiList query="status.includes('decorator') && status.includes('httpMethod')" />
12
12
  *
@@ -11,7 +11,7 @@ function mapTags(tags) {
11
11
  });
12
12
  }
13
13
  /**
14
- * Add tags metadata on the decorated element.
14
+ * Add metadata tags to the decorated element (class or method).
15
15
  *
16
16
  * ## Examples
17
17
  * ### On method
@@ -23,6 +23,15 @@ function mapTags(tags) {
23
23
  * get() {}
24
24
  * }
25
25
  * ```
26
+ * ### On Class
27
+ *
28
+ * ```typescript
29
+ * @Controller("/")
30
+ * @Tags("api")
31
+ * class MyController {
32
+ * get() {}
33
+ * }
34
+ * ```
26
35
  *
27
36
  * @param tags
28
37
  * @decorator
@@ -1 +1 @@
1
- {"version":3,"file":"tags.js","sourceRoot":"","sources":["../../../../src/decorators/operations/tags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,cAAc,EAAE,wBAAwB,EAAC,MAAM,YAAY,CAAC;AAGvF,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAEvD,SAAS,OAAO,CAAC,IAA8B;IAC7C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACtB,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO;gBACL,IAAI,EAAE,GAAG;aACV,CAAC;QACJ,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,IAAI,CAAC,GAAG,IAA8B;IACpD,OAAO,YAAY,CAAC,CAAC,K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,KAAK,cAAc,CAAC,KAAK;gBACvB,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;gBAC1C,MAAM;YAER;gBACE,MAAM,IAAI,wBAAwB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACnD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -11,4 +11,4 @@
11
11
  * @input
12
12
  * @generics
13
13
  */
14
- export declare function Generics(...generics: string[]): (target: any) => void;
14
+ export declare function Generics(...generics: string[]): ClassDecorator;
@@ -16,4 +16,4 @@
16
16
  * @operation
17
17
  * @response
18
18
  */
19
- export declare function AcceptMime(...mimes: string[]): Function;
19
+ export declare function AcceptMime(...mimes: string[]): ClassDecorator & MethodDecorator;
@@ -16,4 +16,4 @@
16
16
  * @classDecorator
17
17
  * @operation
18
18
  */
19
- export declare function Consumes(...consumes: string[]): (...args: any[]) => any;
19
+ export declare function Consumes(...consumes: string[]): ClassDecorator & MethodDecorator;
@@ -46,4 +46,4 @@ import { JsonHeader, JsonHeaders } from "../../interfaces/JsonOpenSpec.js";
46
46
  * @operation
47
47
  * @response
48
48
  */
49
- export declare function Header(headers: string | number | JsonHeaders, value?: string | number | JsonHeader): Function;
49
+ export declare function Header(headers: string | number | JsonHeaders, value?: string | number | JsonHeader): import("./returns.js").ReturnsChainedDecorators;
@@ -7,4 +7,4 @@
7
7
  * @schema
8
8
  * @operation
9
9
  */
10
- export declare function OperationId(operationId: string): (...args: any[]) => any;
10
+ export declare function OperationId(operationId: string): MethodDecorator;
@@ -5,7 +5,7 @@ import { OperationVerbs } from "../../constants/OperationVerbs.js";
5
5
  * ::: warning
6
6
  * Don't use decorator with Ts.ED application.
7
7
  *
8
- * Use theses decorators instead:
8
+ * Use these decorators instead:
9
9
  *
10
10
  * <ApiList query="status.includes('decorator') && status.includes('httpMethod')" />
11
11
  *
@@ -12,4 +12,4 @@
12
12
  * @classDecorator
13
13
  * @operation
14
14
  */
15
- export declare function Path(path: string): (...args: any[]) => any;
15
+ export declare function Path(path: string): ClassDecorator;
@@ -23,4 +23,4 @@
23
23
  * @operation
24
24
  * @response
25
25
  */
26
- export declare function Produces(...produces: string[]): (...args: any[]) => any;
26
+ export declare function Produces(...produces: string[]): ClassDecorator & MethodDecorator;
@@ -48,5 +48,5 @@ import { JsonHeader } from "../../interfaces/JsonOpenSpec.js";
48
48
  * @response
49
49
  * @headers
50
50
  */
51
- export declare function Redirect(url: string, meta?: JsonHeader): Function;
52
- export declare function Redirect(status: number, url: string, meta?: JsonHeader): Function;
51
+ export declare function Redirect(url: string, meta?: JsonHeader): MethodDecorator;
52
+ export declare function Redirect(status: number, url: string, meta?: JsonHeader): MethodDecorator;
@@ -21,7 +21,7 @@ import { OpenSpecSecurity } from "@tsed/openspec";
21
21
  * @classDecorator
22
22
  * @operation
23
23
  */
24
- export declare function Security(name: string, ...scopes: string[]): Function;
24
+ export declare function Security(name: string, ...scopes: string[]): ClassDecorator & MethodDecorator;
25
25
  /**
26
26
  * Add security metadata on the decorated method.
27
27
  *
@@ -53,4 +53,4 @@ export declare function Security(name: string, ...scopes: string[]): Function;
53
53
  * @classDecorator
54
54
  * @operation
55
55
  */
56
- export declare function Security(security: OpenSpecSecurity): Function;
56
+ export declare function Security(security: OpenSpecSecurity): ClassDecorator & MethodDecorator;
@@ -17,4 +17,4 @@
17
17
  * @schema
18
18
  * @operation
19
19
  */
20
- export declare function Summary(summary: string): (...args: any[]) => any;
20
+ export declare function Summary(summary: string): MethodDecorator;
@@ -1,6 +1,6 @@
1
1
  import { OpenSpecTag } from "@tsed/openspec";
2
2
  /**
3
- * Add tags metadata on the decorated element.
3
+ * Add metadata tags to the decorated element (class or method).
4
4
  *
5
5
  * ## Examples
6
6
  * ### On method
@@ -12,6 +12,15 @@ import { OpenSpecTag } from "@tsed/openspec";
12
12
  * get() {}
13
13
  * }
14
14
  * ```
15
+ * ### On Class
16
+ *
17
+ * ```typescript
18
+ * @Controller("/")
19
+ * @Tags("api")
20
+ * class MyController {
21
+ * get() {}
22
+ * }
23
+ * ```
15
24
  *
16
25
  * @param tags
17
26
  * @decorator
@@ -20,4 +29,4 @@ import { OpenSpecTag } from "@tsed/openspec";
20
29
  * @classDecorator
21
30
  * @operation
22
31
  */
23
- export declare function Tags(...tags: (string | OpenSpecTag)[]): (...args: any[]) => any;
32
+ export declare function Tags(...tags: (string | OpenSpecTag)[]): ClassDecorator & MethodDecorator;
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.4.4",
5
+ "version": "8.4.5",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
@@ -37,7 +37,7 @@
37
37
  "tsed"
38
38
  ],
39
39
  "dependencies": {
40
- "@tsed/openspec": "8.4.4",
40
+ "@tsed/openspec": "8.4.5",
41
41
  "change-case": "^5.4.4",
42
42
  "json-schema": "0.4.0",
43
43
  "picomatch": "2.3.1",
@@ -46,11 +46,11 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@apidevtools/swagger-parser": "10.1.0",
49
- "@tsed/barrels": "8.4.4",
50
- "@tsed/core": "8.4.4",
51
- "@tsed/hooks": "8.4.4",
52
- "@tsed/openspec": "8.4.4",
53
- "@tsed/typescript": "8.4.4",
49
+ "@tsed/barrels": "8.4.5",
50
+ "@tsed/core": "8.4.5",
51
+ "@tsed/hooks": "8.4.5",
52
+ "@tsed/openspec": "8.4.5",
53
+ "@tsed/typescript": "8.4.5",
54
54
  "@types/fs-extra": "11.0.4",
55
55
  "@types/json-schema": "7.0.15",
56
56
  "@types/picomatch": "3.0.1",
@@ -63,9 +63,9 @@
63
63
  "webpack": "^5.75.0"
64
64
  },
65
65
  "peerDependencies": {
66
- "@tsed/core": ">=8.4.4",
67
- "@tsed/hooks": ">=8.4.4",
68
- "@tsed/openspec": ">=8.4.4"
66
+ "@tsed/core": ">=8.4.5",
67
+ "@tsed/hooks": ">=8.4.5",
68
+ "@tsed/openspec": ">=8.4.5"
69
69
  },
70
70
  "peerDependenciesMeta": {
71
71
  "@tsed/core": {
@@ -13,7 +13,7 @@ import {JsonEntityStore} from "../../domain/JsonEntityStore.js";
13
13
  * @input
14
14
  * @generics
15
15
  */
16
- export function Generics(...generics: string[]) {
16
+ export function Generics(...generics: string[]): ClassDecorator {
17
17
  return (target: any) => {
18
18
  const storedSchema = JsonEntityStore.from(target);
19
19
 
@@ -20,6 +20,6 @@ import {Produces} from "./produces.js";
20
20
  * @operation
21
21
  * @response
22
22
  */
23
- export function AcceptMime(...mimes: string[]): Function {
23
+ export function AcceptMime(...mimes: string[]): ClassDecorator & MethodDecorator {
24
24
  return useDecorators(Produces(...mimes), StoreSet("acceptMimes", mimes));
25
25
  }
@@ -79,6 +79,7 @@ describe("Consumes", () => {
79
79
 
80
80
  let actualError: any;
81
81
  try {
82
+ // @ts-ignore
82
83
  Consumes("text/json")(Test.prototype, "test", 0);
83
84
  } catch (er) {
84
85
  actualError = er;
@@ -20,7 +20,7 @@ import {JsonEntityFn} from "../common/jsonEntityFn.js";
20
20
  * @classDecorator
21
21
  * @operation
22
22
  */
23
- export function Consumes(...consumes: string[]) {
23
+ export function Consumes(...consumes: string[]): ClassDecorator & MethodDecorator {
24
24
  return JsonEntityFn((store, args) => {
25
25
  switch (store.decoratorType) {
26
26
  case DecoratorTypes.METHOD:
@@ -50,7 +50,7 @@ import {Returns} from "./returns.js";
50
50
  * @operation
51
51
  * @response
52
52
  */
53
- export function Header(headers: string | number | JsonHeaders, value?: string | number | JsonHeader): Function {
53
+ export function Header(headers: string | number | JsonHeaders, value?: string | number | JsonHeader) {
54
54
  if (value !== undefined) {
55
55
  headers = {[headers as string]: value};
56
56
  }
@@ -33,6 +33,7 @@ describe("OperationId", () => {
33
33
  it("should throw error for unsupported usage", () => {
34
34
  let actualError: any;
35
35
  try {
36
+ // @ts-ignore
36
37
  OperationId("id")(class Test {});
37
38
  } catch (er) {
38
39
  actualError = er;
@@ -11,7 +11,7 @@ import {JsonEntityFn} from "../common/jsonEntityFn.js";
11
11
  * @schema
12
12
  * @operation
13
13
  */
14
- export function OperationId(operationId: string) {
14
+ export function OperationId(operationId: string): MethodDecorator {
15
15
  return JsonEntityFn((store, args) => {
16
16
  if (store.decoratorType !== DecoratorTypes.METHOD) {
17
17
  throw new UnsupportedDecoratorType(OperationId, args);
@@ -9,7 +9,7 @@ import {JsonEntityFn} from "../common/jsonEntityFn.js";
9
9
  * ::: warning
10
10
  * Don't use decorator with Ts.ED application.
11
11
  *
12
- * Use theses decorators instead:
12
+ * Use these decorators instead:
13
13
  *
14
14
  * <ApiList query="status.includes('decorator') && status.includes('httpMethod')" />
15
15
  *
@@ -37,6 +37,7 @@ describe("Path", () => {
37
37
 
38
38
  let actualError: any;
39
39
  try {
40
+ // @ts-ignore
40
41
  Path("/")(Test.prototype, "test", 0);
41
42
  } catch (er) {
42
43
  actualError = er;
@@ -16,7 +16,7 @@ import {JsonEntityFn} from "../common/jsonEntityFn.js";
16
16
  * @classDecorator
17
17
  * @operation
18
18
  */
19
- export function Path(path: string) {
19
+ export function Path(path: string): ClassDecorator {
20
20
  return JsonEntityFn((store, args) => {
21
21
  if (store.decoratorType !== DecoratorTypes.CLASS) {
22
22
  throw new UnsupportedDecoratorType(Path, args);
@@ -79,6 +79,7 @@ describe("Produces", () => {
79
79
 
80
80
  let actualError: any;
81
81
  try {
82
+ // @ts-ignore
82
83
  Produces("text/json")(Test.prototype, "test", 0);
83
84
  } catch (er) {
84
85
  actualError = er;
@@ -27,7 +27,7 @@ import {JsonEntityFn} from "../common/jsonEntityFn.js";
27
27
  * @operation
28
28
  * @response
29
29
  */
30
- export function Produces(...produces: string[]) {
30
+ export function Produces(...produces: string[]): ClassDecorator & MethodDecorator {
31
31
  return JsonEntityFn((store, args) => {
32
32
  switch (store.decoratorType) {
33
33
  case DecoratorTypes.METHOD:
@@ -53,9 +53,9 @@ import {Returns} from "./returns.js";
53
53
  * @response
54
54
  * @headers
55
55
  */
56
- export function Redirect(url: string, meta?: JsonHeader): Function;
57
- export function Redirect(status: number, url: string, meta?: JsonHeader): Function;
58
- export function Redirect(...args: any[]): Function {
56
+ export function Redirect(url: string, meta?: JsonHeader): MethodDecorator;
57
+ export function Redirect(status: number, url: string, meta?: JsonHeader): MethodDecorator;
58
+ export function Redirect(...args: any[]): MethodDecorator {
59
59
  const {status, url, meta} = args.reduce(
60
60
  (options: any, value: any) => {
61
61
  if (isNumber(value)) {
@@ -152,6 +152,7 @@ describe("Security", () => {
152
152
 
153
153
  let actualError: any;
154
154
  try {
155
+ // @ts-ignore
155
156
  Security("POST", "/")(Test.prototype, "test", 0);
156
157
  } catch (er) {
157
158
  actualError = er;
@@ -25,7 +25,7 @@ import {JsonEntityFn} from "../common/jsonEntityFn.js";
25
25
  * @classDecorator
26
26
  * @operation
27
27
  */
28
- export function Security(name: string, ...scopes: string[]): Function;
28
+ export function Security(name: string, ...scopes: string[]): ClassDecorator & MethodDecorator;
29
29
  /**
30
30
  * Add security metadata on the decorated method.
31
31
  *
@@ -57,8 +57,8 @@ export function Security(name: string, ...scopes: string[]): Function;
57
57
  * @classDecorator
58
58
  * @operation
59
59
  */
60
- export function Security(security: OpenSpecSecurity): Function;
61
- export function Security(nameOrSecurity: string | OpenSpecSecurity, ...scopes: string[]): Function {
60
+ export function Security(security: OpenSpecSecurity): ClassDecorator & MethodDecorator;
61
+ export function Security(nameOrSecurity: string | OpenSpecSecurity, ...scopes: string[]): ClassDecorator & MethodDecorator {
62
62
  return JsonEntityFn((store, args) => {
63
63
  switch (store.decoratorType) {
64
64
  case DecoratorTypes.METHOD:
@@ -35,6 +35,7 @@ describe("Summary", () => {
35
35
  it("should throw error for unsupported usage", () => {
36
36
  let actualError: any;
37
37
  try {
38
+ // @ts-ignore
38
39
  Summary("summary")(class Test {});
39
40
  } catch (er) {
40
41
  actualError = er;
@@ -21,7 +21,7 @@ import {JsonEntityFn} from "../common/jsonEntityFn.js";
21
21
  * @schema
22
22
  * @operation
23
23
  */
24
- export function Summary(summary: string) {
24
+ export function Summary(summary: string): MethodDecorator {
25
25
  return JsonEntityFn((store, args) => {
26
26
  if (store.decoratorType !== DecoratorTypes.METHOD) {
27
27
  throw new UnsupportedDecoratorType(Summary, args);
@@ -103,6 +103,7 @@ describe("Tags", () => {
103
103
 
104
104
  let actualError: any;
105
105
  try {
106
+ // @ts-ignore
106
107
  Tags("tags")(Test.prototype, "test", 0);
107
108
  } catch (er) {
108
109
  actualError = er;
@@ -16,7 +16,7 @@ function mapTags(tags: (string | OpenSpecTag)[]) {
16
16
  }
17
17
 
18
18
  /**
19
- * Add tags metadata on the decorated element.
19
+ * Add metadata tags to the decorated element (class or method).
20
20
  *
21
21
  * ## Examples
22
22
  * ### On method
@@ -28,6 +28,15 @@ function mapTags(tags: (string | OpenSpecTag)[]) {
28
28
  * get() {}
29
29
  * }
30
30
  * ```
31
+ * ### On Class
32
+ *
33
+ * ```typescript
34
+ * @Controller("/")
35
+ * @Tags("api")
36
+ * class MyController {
37
+ * get() {}
38
+ * }
39
+ * ```
31
40
  *
32
41
  * @param tags
33
42
  * @decorator
@@ -36,7 +45,7 @@ function mapTags(tags: (string | OpenSpecTag)[]) {
36
45
  * @classDecorator
37
46
  * @operation
38
47
  */
39
- export function Tags(...tags: (string | OpenSpecTag)[]) {
48
+ export function Tags(...tags: (string | OpenSpecTag)[]): ClassDecorator & MethodDecorator {
40
49
  return JsonEntityFn((store, args) => {
41
50
  switch (store.decoratorType) {
42
51
  case DecoratorTypes.METHOD: