@midwayjs/bull-board 3.11.18 → 3.12.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.
package/dist/adapter.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AppControllerRoute, AppViewRoute, BullBoardQueues, ControllerHandlerReturnType, IServerAdapter } from '@bull-board/api/dist/typings/app';
1
+ import type { AppControllerRoute, AppViewRoute, BullBoardQueues, ControllerHandlerReturnType, IServerAdapter, UIConfig } from '@bull-board/api/dist/typings/app';
2
2
  export declare class MidwayAdapter implements IServerAdapter {
3
3
  private basePath;
4
4
  private bullBoardQueues;
@@ -8,17 +8,19 @@ export declare class MidwayAdapter implements IServerAdapter {
8
8
  private apiRoutes;
9
9
  private staticCache;
10
10
  setBasePath(path: string): MidwayAdapter;
11
+ setUIConfig(config: UIConfig): MidwayAdapter;
11
12
  setStaticPath(staticsRoute: string, staticsPath: string): MidwayAdapter;
12
13
  setViewsPath(viewPath: string): MidwayAdapter;
13
14
  setErrorHandler(handler: (error: Error) => ControllerHandlerReturnType): this;
14
15
  setApiRoutes(routes: AppControllerRoute[]): MidwayAdapter;
15
16
  setEntryRoute(routeDef: AppViewRoute): MidwayAdapter;
17
+ getEntryRoute(): AppViewRoute;
16
18
  setQueues(bullBoardQueues: BullBoardQueues): MidwayAdapter;
17
19
  getViewRoutes(): string[];
18
20
  matchApiRoutes(method: string, url: string): AppControllerRoute;
19
21
  getStaticRoutes(): string;
20
22
  renderStatic(filename: any): Promise<any>;
21
- renderView(filename: any): Promise<unknown>;
23
+ renderView(filename: any, params?: {}): Promise<unknown>;
22
24
  runAPI(route: any, query: any): Promise<any>;
23
25
  }
24
26
  //# sourceMappingURL=adapter.d.ts.map
package/dist/adapter.js CHANGED
@@ -14,6 +14,10 @@ class MidwayAdapter {
14
14
  this.basePath = path;
15
15
  return this;
16
16
  }
17
+ setUIConfig(config) {
18
+ // 这里没用
19
+ return this;
20
+ }
17
21
  setStaticPath(staticsRoute, staticsPath) {
18
22
  this.statics = { route: staticsRoute, path: staticsPath };
19
23
  return this;
@@ -37,6 +41,9 @@ class MidwayAdapter {
37
41
  this.entryRoute = routeDef;
38
42
  return this;
39
43
  }
44
+ getEntryRoute() {
45
+ return this.entryRoute;
46
+ }
40
47
  setQueues(bullBoardQueues) {
41
48
  this.bullBoardQueues = bullBoardQueues;
42
49
  return this;
@@ -74,7 +81,7 @@ class MidwayAdapter {
74
81
  this.staticCache.set(filename, content);
75
82
  return content;
76
83
  }
77
- async renderView(filename) {
84
+ async renderView(filename, params = {}) {
78
85
  const basePath = this.basePath.endsWith('/')
79
86
  ? this.basePath
80
87
  : `${this.basePath}/`;
@@ -83,7 +90,7 @@ class MidwayAdapter {
83
90
  }
84
91
  filename = (0, path_1.join)(this.viewPath, filename);
85
92
  return new Promise((resolve, reject) => {
86
- ejs.renderFile(filename, { basePath, cache: true }, {
93
+ ejs.renderFile(filename, { basePath, cache: true, ...params }, {
87
94
  root: this.viewPath,
88
95
  }, (err, result) => {
89
96
  if (err) {
@@ -1,11 +1,9 @@
1
1
  import { IMiddleware, IMidwayApplication, IMidwayContext, NextFunction } from '@midwayjs/core';
2
2
  import * as bull from '@midwayjs/bull';
3
+ import { BullBoardOption } from './interface';
3
4
  export declare class BoardMiddleware implements IMiddleware<IMidwayContext, NextFunction, unknown> {
4
5
  framework: bull.Framework;
5
- bullBoardConfig: {
6
- basePath?: string;
7
- adapterOptions?: any;
8
- };
6
+ bullBoardConfig: BullBoardOption;
9
7
  private basePath;
10
8
  private serverAdapter;
11
9
  init(): Promise<void>;
@@ -43,6 +43,9 @@ let BoardMiddleware = class BoardMiddleware {
43
43
  (0, api_1.createBullBoard)({
44
44
  queues: wrapQueues,
45
45
  serverAdapter: this.serverAdapter,
46
+ options: {
47
+ uiConfig: this.bullBoardConfig.uiConfig,
48
+ },
46
49
  });
47
50
  this.serverAdapter.setBasePath(this.basePath);
48
51
  }
@@ -59,7 +62,12 @@ let BoardMiddleware = class BoardMiddleware {
59
62
  content = await this.serverAdapter.renderStatic(routePath);
60
63
  }
61
64
  else if (this.serverAdapter.getViewRoutes().indexOf(routePath) !== -1) {
62
- content = await this.serverAdapter.renderView(routePath);
65
+ const entryRoute = this.serverAdapter.getEntryRoute();
66
+ const { name, params } = entryRoute.handler({
67
+ basePath: this.basePath,
68
+ uiConfig: this.bullBoardConfig.uiConfig,
69
+ });
70
+ content = await this.serverAdapter.renderView(name, params);
63
71
  }
64
72
  else {
65
73
  const matchRoute = this.serverAdapter.matchApiRoutes(req.method, routePath);
@@ -94,7 +102,12 @@ let BoardMiddleware = class BoardMiddleware {
94
102
  content = await this.serverAdapter.renderStatic(routePath);
95
103
  }
96
104
  else if (this.serverAdapter.getViewRoutes().indexOf(routePath) !== -1) {
97
- content = await this.serverAdapter.renderView(routePath);
105
+ const entryRoute = this.serverAdapter.getEntryRoute();
106
+ const { name, params } = entryRoute.handler({
107
+ basePath: this.basePath,
108
+ uiConfig: this.bullBoardConfig.uiConfig,
109
+ });
110
+ content = await this.serverAdapter.renderView(name, params);
98
111
  }
99
112
  else {
100
113
  const matchRoute = this.serverAdapter.matchApiRoutes(ctx.method, routePath);
@@ -44,6 +44,7 @@ BullBoardConfiguration = __decorate([
44
44
  default: {
45
45
  bullBoard: {
46
46
  basePath: '/ui',
47
+ uiConfig: {},
47
48
  adapterOptions: {
48
49
  readOnlyMode: false,
49
50
  },
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { BullBoardConfiguration as Configuration } from './configuration';
2
2
  export * from './board.middleware';
3
+ export * from './interface';
3
4
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -18,4 +18,5 @@ exports.Configuration = void 0;
18
18
  var configuration_1 = require("./configuration");
19
19
  Object.defineProperty(exports, "Configuration", { enumerable: true, get: function () { return configuration_1.BullBoardConfiguration; } });
20
20
  __exportStar(require("./board.middleware"), exports);
21
+ __exportStar(require("./interface"), exports);
21
22
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ import type { QueueAdapterOptions, UIConfig } from "@bull-board/api/dist/typings/app";
2
+ export interface BullBoardOption {
3
+ basePath?: string;
4
+ uiConfig?: UIConfig;
5
+ adapterOptions?: QueueAdapterOptions;
6
+ }
7
+ //# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=interface.js.map
package/index.d.ts CHANGED
@@ -1,13 +1,10 @@
1
- import { QueueAdapterOptions } from '@bull-board/api/dist/typings/app';
2
1
  import '@midwayjs/bull';
2
+ import { BullBoardOption } from './dist/index';
3
3
  export * from './dist/index';
4
4
 
5
5
  declare module '@midwayjs/core/dist/interface' {
6
6
  // eslint-disable-next-line
7
7
  interface MidwayConfig {
8
- bullBoard?: {
9
- basePath?: string;
10
- adapterOptions?: QueueAdapterOptions;
11
- };
8
+ bullBoard?: PowerPartial<BullBoardOption>;
12
9
  }
13
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/bull-board",
3
- "version": "3.11.18",
3
+ "version": "3.12.1",
4
4
  "description": "midway component for bull",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
@@ -24,19 +24,19 @@
24
24
  ],
25
25
  "license": "MIT",
26
26
  "devDependencies": {
27
- "@midwayjs/core": "^3.11.15",
28
- "@midwayjs/express": "^3.11.15",
29
- "@midwayjs/koa": "^3.11.15",
30
- "@midwayjs/mock": "^3.11.15"
27
+ "@midwayjs/core": "^3.12.1",
28
+ "@midwayjs/express": "^3.12.1",
29
+ "@midwayjs/koa": "^3.12.1",
30
+ "@midwayjs/mock": "^3.12.1"
31
31
  },
32
32
  "dependencies": {
33
- "@bull-board/api": "4.6.4",
34
- "@bull-board/ui": "4.6.4",
35
- "@midwayjs/bull": "^3.11.18",
33
+ "@bull-board/api": "5.8.0",
34
+ "@bull-board/ui": "5.8.0",
35
+ "@midwayjs/bull": "^3.12.1",
36
36
  "ejs": "3.1.9"
37
37
  },
38
38
  "engines": {
39
39
  "node": ">=12"
40
40
  },
41
- "gitHead": "c5646f6fcae5b8e0ff1520ce37a5c54dc73502ce"
41
+ "gitHead": "48413b87b12354cb8207de6aa58e0a4ca22ea000"
42
42
  }