@tsed/schema 7.81.0-rc.1 → 7.81.1

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.
@@ -3,36 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Security = void 0;
4
4
  const core_1 = require("@tsed/core");
5
5
  const jsonEntityFn_js_1 = require("../common/jsonEntityFn.js");
6
- /**
7
- * Add security metadata on the decorated method.
8
- *
9
- * ## Examples
10
- * ### On method
11
- *
12
- * ```typescript
13
- * @Controller("/")
14
- * class ModelCtrl {
15
- * @Security("write:calendars")
16
- * async method() {}
17
- * }
18
- * ```
19
- *
20
- * @param name
21
- * @param scopes
22
- * @decorator
23
- * @swagger
24
- * @schema
25
- * @classDecorator
26
- * @operation
27
- */
28
- function Security(name, ...scopes) {
6
+ function Security(nameOrSecurity, ...scopes) {
29
7
  return (0, jsonEntityFn_js_1.JsonEntityFn)((store, args) => {
30
8
  switch (store.decoratorType) {
31
9
  case core_1.DecoratorTypes.METHOD:
32
- store.operation.addSecurityScopes(name, scopes);
10
+ if (Array.isArray(nameOrSecurity)) {
11
+ store.operation.security(nameOrSecurity);
12
+ }
13
+ else {
14
+ store.operation.addSecurityScopes(nameOrSecurity, scopes);
15
+ }
33
16
  break;
34
17
  case core_1.DecoratorTypes.CLASS:
35
- (0, core_1.decorateMethodsOf)(args[0], Security(name, ...scopes));
18
+ if (Array.isArray(nameOrSecurity)) {
19
+ (0, core_1.decorateMethodsOf)(args[0], Security(nameOrSecurity));
20
+ }
21
+ else {
22
+ (0, core_1.decorateMethodsOf)(args[0], Security(nameOrSecurity, ...scopes));
23
+ }
36
24
  break;
37
25
  default:
38
26
  throw new core_1.UnsupportedDecoratorType(Security, args);
@@ -1 +1 @@
1
- {"version":3,"file":"security.js","sourceRoot":"","sources":["../../../../src/decorators/operations/security.ts"],"names":[],"mappings":";;;AAAA,qCAAuF;AACvF,+DAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;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,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC;iBACtD;qBAAM;oBACL,IAAA,wBAAiB,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,cAAc,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;iBACjE;gBACD,MAAM;YAER;gBACE,MAAM,IAAI,+BAAwB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;SACtD;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAtBD,4BAsBC"}
@@ -1,35 +1,23 @@
1
1
  import { decorateMethodsOf, DecoratorTypes, UnsupportedDecoratorType } from "@tsed/core";
2
2
  import { JsonEntityFn } from "../common/jsonEntityFn.js";
3
- /**
4
- * Add security metadata on the decorated method.
5
- *
6
- * ## Examples
7
- * ### On method
8
- *
9
- * ```typescript
10
- * @Controller("/")
11
- * class ModelCtrl {
12
- * @Security("write:calendars")
13
- * async method() {}
14
- * }
15
- * ```
16
- *
17
- * @param name
18
- * @param scopes
19
- * @decorator
20
- * @swagger
21
- * @schema
22
- * @classDecorator
23
- * @operation
24
- */
25
- export function Security(name, ...scopes) {
3
+ export function Security(nameOrSecurity, ...scopes) {
26
4
  return JsonEntityFn((store, args) => {
27
5
  switch (store.decoratorType) {
28
6
  case DecoratorTypes.METHOD:
29
- store.operation.addSecurityScopes(name, scopes);
7
+ if (Array.isArray(nameOrSecurity)) {
8
+ store.operation.security(nameOrSecurity);
9
+ }
10
+ else {
11
+ store.operation.addSecurityScopes(nameOrSecurity, scopes);
12
+ }
30
13
  break;
31
14
  case DecoratorTypes.CLASS:
32
- decorateMethodsOf(args[0], Security(name, ...scopes));
15
+ if (Array.isArray(nameOrSecurity)) {
16
+ decorateMethodsOf(args[0], Security(nameOrSecurity));
17
+ }
18
+ else {
19
+ decorateMethodsOf(args[0], Security(nameOrSecurity, ...scopes));
20
+ }
33
21
  break;
34
22
  default:
35
23
  throw new UnsupportedDecoratorType(Security, args);
@@ -1 +1 @@
1
- {"version":3,"file":"security.js","sourceRoot":"","sources":["../../../../src/decorators/operations/security.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,cAAc,EAAE,wBAAwB,EAAC,MAAM,YAAY,CAAC;AACvF,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,GAAG,MAAgB;IACxD,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QAClC,QAAQ,KAAK,CAAC,aAAa,EAAE;YAC3B,KAAK,cAAc,CAAC,MAAM;gBACxB,KAAK,CAAC,SAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;gBACjD,MAAM;YACR,KAAK,cAAc,CAAC,KAAK;gBACvB,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;gBACtD,MAAM;YAER;gBACE,MAAM,IAAI,wBAAwB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;SACtD;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"security.js","sourceRoot":"","sources":["../../../../src/decorators/operations/security.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,cAAc,EAAE,wBAAwB,EAAC,MAAM,YAAY,CAAC;AACvF,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AA0DvD,MAAM,UAAU,QAAQ,CAAC,cAAyC,EAAE,GAAG,MAAgB;IACrF,OAAO,YAAY,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QAClC,QAAQ,KAAK,CAAC,aAAa,EAAE;YAC3B,KAAK,cAAc,CAAC,MAAM;gBACxB,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE;oBACjC,KAAK,CAAC,SAAU,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;iBAC3C;qBAAM;oBACL,KAAK,CAAC,SAAU,CAAC,iBAAiB,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;iBAC5D;gBACD,MAAM;YACR,KAAK,cAAc,CAAC,KAAK;gBACvB,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE;oBACjC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC;iBACtD;qBAAM;oBACL,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,cAAc,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;iBACjE;gBACD,MAAM;YAER;gBACE,MAAM,IAAI,wBAAwB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;SACtD;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { OpenSpecSecurity } from "@tsed/openspec";
1
2
  /**
2
3
  * Add security metadata on the decorated method.
3
4
  *
@@ -20,4 +21,36 @@
20
21
  * @classDecorator
21
22
  * @operation
22
23
  */
23
- export declare function Security(name: string, ...scopes: string[]): (...args: any[]) => any;
24
+ export declare function Security(name: string, ...scopes: string[]): Function;
25
+ /**
26
+ * Add security metadata on the decorated method.
27
+ *
28
+ * You can use it to add multiple authentication types.
29
+ * See <https://swagger.io/docs/specification/authentication/#multiple>.
30
+ *
31
+ * ## Examples
32
+ * ### On method
33
+ *
34
+ * ```typescript
35
+ * @Controller("/")
36
+ * class ModelCtrl {
37
+ * @Security([{ "A": ["scope-1"] }, { "B": [], "C": ["scope-2", "scope-3"]}])
38
+ * async method() {}
39
+ * }
40
+ * ```
41
+ * this will add the following security metadata
42
+ * ```yaml
43
+ * security: # A OR (B AND C)
44
+ * - A: ["scope-1"]
45
+ * - B: []
46
+ * C: ["scope-2", "scope-3"]
47
+ * ```
48
+ *
49
+ * @param security
50
+ * @decorator
51
+ * @swagger
52
+ * @schema
53
+ * @classDecorator
54
+ * @operation
55
+ */
56
+ export declare function Security(security: OpenSpecSecurity): Function;
@@ -1,3 +1,4 @@
1
+ import { OpenSpecSecurity } from "@tsed/openspec";
1
2
  /**
2
3
  * Add security metadata on the decorated method.
3
4
  *
@@ -20,4 +21,36 @@
20
21
  * @classDecorator
21
22
  * @operation
22
23
  */
23
- export declare function Security(name: string, ...scopes: string[]): (...args: any[]) => any;
24
+ export declare function Security(name: string, ...scopes: string[]): Function;
25
+ /**
26
+ * Add security metadata on the decorated method.
27
+ *
28
+ * You can use it to add multiple authentication types.
29
+ * See <https://swagger.io/docs/specification/authentication/#multiple>.
30
+ *
31
+ * ## Examples
32
+ * ### On method
33
+ *
34
+ * ```typescript
35
+ * @Controller("/")
36
+ * class ModelCtrl {
37
+ * @Security([{ "A": ["scope-1"] }, { "B": [], "C": ["scope-2", "scope-3"]}])
38
+ * async method() {}
39
+ * }
40
+ * ```
41
+ * this will add the following security metadata
42
+ * ```yaml
43
+ * security: # A OR (B AND C)
44
+ * - A: ["scope-1"]
45
+ * - B: []
46
+ * C: ["scope-2", "scope-3"]
47
+ * ```
48
+ *
49
+ * @param security
50
+ * @decorator
51
+ * @swagger
52
+ * @schema
53
+ * @classDecorator
54
+ * @operation
55
+ */
56
+ export declare function Security(security: OpenSpecSecurity): Function;
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": "commonjs",
5
- "version": "7.81.0-rc.1",
5
+ "version": "7.81.1",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/cjs/index.js",
8
8
  "module": "./lib/esm/index.js",
@@ -37,7 +37,7 @@
37
37
  "tsed"
38
38
  ],
39
39
  "dependencies": {
40
- "@tsed/openspec": "7.81.0-rc.1",
40
+ "@tsed/openspec": "7.81.1",
41
41
  "change-case": "^4.1.2",
42
42
  "fs-extra": "^11.2.0",
43
43
  "json-schema": "0.4.0",
@@ -47,10 +47,10 @@
47
47
  },
48
48
  "devDependencies": {
49
49
  "@apidevtools/swagger-parser": "10.1.0",
50
- "@tsed/barrels": "7.81.0-rc.1",
51
- "@tsed/core": "7.81.0-rc.1",
52
- "@tsed/openspec": "7.81.0-rc.1",
53
- "@tsed/typescript": "7.81.0-rc.1",
50
+ "@tsed/barrels": "7.81.1",
51
+ "@tsed/core": "7.81.1",
52
+ "@tsed/openspec": "7.81.1",
53
+ "@tsed/typescript": "7.81.1",
54
54
  "@types/fs-extra": "11.0.4",
55
55
  "@types/json-schema": "7.0.15",
56
56
  "@types/picomatch": "2.3.3",
@@ -61,8 +61,8 @@
61
61
  "vitest": "2.0.4"
62
62
  },
63
63
  "peerDependencies": {
64
- "@tsed/core": "7.81.0-rc.1",
65
- "@tsed/openspec": "7.81.0-rc.1"
64
+ "@tsed/core": "7.81.1",
65
+ "@tsed/openspec": "7.81.1"
66
66
  },
67
67
  "peerDependenciesMeta": {
68
68
  "@tsed/core": {
@@ -78,8 +78,5 @@
78
78
  },
79
79
  "homepage": "https://github.com/tsedio/tsed/tree/production/packages/specs/schema",
80
80
  "author": "Romain Lenzotti",
81
- "license": "MIT",
82
- "publishConfig": {
83
- "tag": "rc"
84
- }
81
+ "license": "MIT"
85
82
  }