@kaapi/kaapi 0.0.11 → 0.0.12

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.
@@ -2,6 +2,21 @@ import { HandlerDecorations, InternalRouteOptionType, Lifecycle, MergeType, ReqR
2
2
  import { ILogger } from './log';
3
3
  import { KaapiServerRoute } from '@kaapi/server';
4
4
  import { KaapiOpenAPI, KaapiPostman } from './docs/generators';
5
+ import { BaseAuthUtil } from '@novice1/api-doc-generator/lib/utils/auth/baseAuthUtils';
6
+ /**
7
+ *
8
+ * Set of tools
9
+ *
10
+ * ```ts
11
+ * log
12
+ * openapi
13
+ * postman
14
+ * server
15
+ * route(...)
16
+ * scheme(...)
17
+ * strategy(...)
18
+ * ```
19
+ */
5
20
  export interface KaapiTools {
6
21
  readonly log: ILogger;
7
22
  route<Refs extends ReqRef = ReqRefDefaults>(serverRoute: KaapiServerRoute<Refs>, handler?: HandlerDecorations | Lifecycle.Method<Refs, Lifecycle.ReturnValue<Refs>>): this;
@@ -11,6 +26,37 @@ export interface KaapiTools {
11
26
  strategy(name: MergeType<InternalRouteOptionType, RouteOptionTypes>['Strategy'], scheme: string, options?: object): void;
12
27
  server: Server;
13
28
  }
29
+ /**
30
+ * Interface to extend kaapi app functionalities.
31
+ * ```ts
32
+ * const app = new Kaapi({
33
+ * extend: [plugin]
34
+ * })
35
+ * // or
36
+ * app.extend(plugin)
37
+ * // or
38
+ * app.extend([plugin1, plugin2])
39
+ * ```
40
+ */
14
41
  export interface KaapiPlugin {
15
42
  integrate(t: KaapiTools): void | Promise<void>;
16
43
  }
44
+ /**
45
+ * AuthDesign plugin
46
+ */
47
+ export declare abstract class AuthDesign implements KaapiPlugin {
48
+ integrate(t: KaapiTools): Promise<void>;
49
+ /**
50
+ * Whatever needs to be done to complete the integration.
51
+ * (e.g.: register a route, ...)
52
+ */
53
+ integrateHook(_t: KaapiTools): void | Promise<void>;
54
+ /**
55
+ * Returns the schema used for the documentation
56
+ */
57
+ abstract docs(): BaseAuthUtil | undefined;
58
+ /**
59
+ * Where authentication schemes and strategies should be registered.
60
+ */
61
+ abstract integrateStrategy(t: KaapiTools): void | Promise<void>;
62
+ }
@@ -1,3 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthDesign = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const api_doc_generator_1 = require("@novice1/api-doc-generator");
6
+ /**
7
+ * AuthDesign plugin
8
+ */
9
+ class AuthDesign {
10
+ integrate(t) {
11
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
+ var _a, _b, _c;
13
+ yield this.integrateStrategy(t);
14
+ const securityScheme = this.docs();
15
+ if (securityScheme) {
16
+ (_a = t.openapi) === null || _a === void 0 ? void 0 : _a.addSecurityScheme(securityScheme).setDefaultSecurity(securityScheme);
17
+ if (securityScheme instanceof api_doc_generator_1.OAuth2Util && !securityScheme.getHost() && ((_b = t.postman) === null || _b === void 0 ? void 0 : _b.getHost().length)) {
18
+ securityScheme.setHost(t.postman.getHost()[0]);
19
+ }
20
+ (_c = t.postman) === null || _c === void 0 ? void 0 : _c.setDefaultSecurity(securityScheme);
21
+ }
22
+ yield this.integrateHook(t);
23
+ });
24
+ }
25
+ /**
26
+ * Whatever needs to be done to complete the integration.
27
+ * (e.g.: register a route, ...)
28
+ */
29
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
30
+ integrateHook(_t) {
31
+ }
32
+ }
33
+ exports.AuthDesign = AuthDesign;
3
34
  //# sourceMappingURL=plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/services/plugin.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/services/plugin.ts"],"names":[],"mappings":";;;;AAKA,kEAAwD;AAoDxD;;GAEG;AACH,MAAsB,UAAU;IACtB,SAAS,CAAC,CAAa;;;YAEzB,MAAM,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAA;YAE/B,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YACnC,IAAI,cAAc,EAAE,CAAC;gBACjB,MAAA,CAAC,CAAC,OAAO,0CAAE,iBAAiB,CAAC,cAAc,EACtC,kBAAkB,CAAC,cAAc,CAAC,CAAC;gBACxC,IAAI,cAAc,YAAY,8BAAU,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,KAAI,MAAA,CAAC,CAAC,OAAO,0CAAE,OAAO,GAAG,MAAM,CAAA,EAAE,CAAC;oBACnG,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;gBAClD,CAAC;gBACD,MAAA,CAAC,CAAC,OAAO,0CAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC;YAClD,CAAC;YAED,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAA;QAC/B,CAAC;KAAA;IAED;;;OAGG;IACH,6DAA6D;IAC7D,aAAa,CAAC,EAAc;IAE5B,CAAC;CAWJ;AApCD,gCAoCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaapi/kaapi",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "private": false,
5
5
  "description": "TypeScript-based framework",
6
6
  "main": "lib/index.js",
@@ -26,7 +26,7 @@
26
26
  "swagger-ui-dist": "^5.27.1",
27
27
  "tslib": "^2.8.1",
28
28
  "winston": "^3.17.0",
29
- "@kaapi/server": "^0.0.11"
29
+ "@kaapi/server": "^0.0.12"
30
30
  },
31
31
  "scripts": {
32
32
  "lint": "eslint .",