@nocobase/server 2.0.0-alpha.54 → 2.0.0-alpha.55

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 (2) hide show
  1. package/lib/gateway/errors.js +47 -14
  2. package/package.json +16 -16
@@ -44,6 +44,15 @@ __export(errors_exports, {
44
44
  module.exports = __toCommonJS(errors_exports);
45
45
  var import_app_supervisor = require("../app-supervisor");
46
46
  var import_lodash = __toESM(require("lodash"));
47
+ function getMaintaining(app) {
48
+ var _a;
49
+ return (_a = app == null ? void 0 : app.getMaintaining) == null ? void 0 : _a.call(app);
50
+ }
51
+ __name(getMaintaining, "getMaintaining");
52
+ function getAppName(app) {
53
+ return (app == null ? void 0 : app.name) || "unknown";
54
+ }
55
+ __name(getAppName, "getAppName");
47
56
  const errors = {
48
57
  APP_NOT_FOUND: {
49
58
  status: 404,
@@ -53,7 +62,10 @@ const errors = {
53
62
  APP_ERROR: {
54
63
  status: 503,
55
64
  message: /* @__PURE__ */ __name(({ app }) => {
56
- const error = import_app_supervisor.AppSupervisor.getInstance().appErrors[app == null ? void 0 : app.name];
65
+ if (!(app == null ? void 0 : app.name)) {
66
+ return "";
67
+ }
68
+ const error = import_app_supervisor.AppSupervisor.getInstance().appErrors[app.name];
57
69
  if (!error) {
58
70
  return "";
59
71
  }
@@ -64,10 +76,16 @@ const errors = {
64
76
  return message;
65
77
  }, "message"),
66
78
  code: /* @__PURE__ */ __name(({ app }) => {
67
- const error = import_app_supervisor.AppSupervisor.getInstance().appErrors[app == null ? void 0 : app.name];
68
- return error["code"] || "APP_ERROR";
79
+ if (!(app == null ? void 0 : app.name)) {
80
+ return "APP_ERROR";
81
+ }
82
+ const error = import_app_supervisor.AppSupervisor.getInstance().appErrors[app.name];
83
+ return (error == null ? void 0 : error["code"]) || "APP_ERROR";
69
84
  }, "code"),
70
- command: /* @__PURE__ */ __name(({ app }) => app.getMaintaining().command, "command"),
85
+ command: /* @__PURE__ */ __name(({ app }) => {
86
+ var _a;
87
+ return (_a = getMaintaining(app)) == null ? void 0 : _a.command;
88
+ }, "command"),
71
89
  maintaining: true
72
90
  },
73
91
  APP_PREPARING: {
@@ -77,17 +95,17 @@ const errors = {
77
95
  },
78
96
  APP_STARTING: {
79
97
  status: 503,
80
- message: /* @__PURE__ */ __name(({ app }) => app.maintainingMessage, "message"),
98
+ message: /* @__PURE__ */ __name(({ app }) => (app == null ? void 0 : app.maintainingMessage) || "", "message"),
81
99
  maintaining: true
82
100
  },
83
101
  APP_STOPPED: {
84
102
  status: 503,
85
- message: /* @__PURE__ */ __name(({ app }) => `application ${app == null ? void 0 : app.name} is stopped`, "message"),
103
+ message: /* @__PURE__ */ __name(({ app }) => `application ${getAppName(app)} is stopped`, "message"),
86
104
  maintaining: true
87
105
  },
88
106
  APP_INITIALIZED: {
89
107
  status: 503,
90
- message: /* @__PURE__ */ __name(({ app }) => `application ${app == null ? void 0 : app.name} is initialized, please refresh the page`, "message"),
108
+ message: /* @__PURE__ */ __name(({ app }) => `application ${getAppName(app)} is initialized, waiting for command`, "message"),
91
109
  maintaining: true
92
110
  },
93
111
  APP_INITIALIZING: {
@@ -98,25 +116,40 @@ const errors = {
98
116
  COMMAND_ERROR: {
99
117
  status: 503,
100
118
  maintaining: true,
101
- message: /* @__PURE__ */ __name(({ app }) => app.getMaintaining().error.message, "message"),
102
- command: /* @__PURE__ */ __name(({ app }) => app.getMaintaining().command, "command")
119
+ message: /* @__PURE__ */ __name(({ app }) => {
120
+ var _a, _b;
121
+ return ((_b = (_a = getMaintaining(app)) == null ? void 0 : _a.error) == null ? void 0 : _b.message) || "";
122
+ }, "message"),
123
+ command: /* @__PURE__ */ __name(({ app }) => {
124
+ var _a;
125
+ return (_a = getMaintaining(app)) == null ? void 0 : _a.command;
126
+ }, "command")
103
127
  },
104
128
  COMMAND_END: {
105
129
  status: 503,
106
130
  maintaining: true,
107
- message: /* @__PURE__ */ __name(({ app }) => `${app.getMaintaining().command.name} running end`, "message"),
108
- command: /* @__PURE__ */ __name(({ app }) => app.getMaintaining().command, "command")
131
+ message: /* @__PURE__ */ __name(({ app }) => {
132
+ var _a, _b;
133
+ return `${((_b = (_a = getMaintaining(app)) == null ? void 0 : _a.command) == null ? void 0 : _b.name) || "command"} running end`;
134
+ }, "message"),
135
+ command: /* @__PURE__ */ __name(({ app }) => {
136
+ var _a;
137
+ return (_a = getMaintaining(app)) == null ? void 0 : _a.command;
138
+ }, "command")
109
139
  },
110
140
  APP_COMMANDING: {
111
141
  status: 503,
112
142
  maintaining: true,
113
- message: /* @__PURE__ */ __name(({ app, message }) => message || app.maintainingMessage, "message"),
114
- command: /* @__PURE__ */ __name(({ app, command }) => command || app.getMaintaining().command, "command")
143
+ message: /* @__PURE__ */ __name(({ app, message }) => message || (app == null ? void 0 : app.maintainingMessage) || "", "message"),
144
+ command: /* @__PURE__ */ __name(({ app, command }) => {
145
+ var _a;
146
+ return command || ((_a = getMaintaining(app)) == null ? void 0 : _a.command);
147
+ }, "command")
115
148
  },
116
149
  APP_RUNNING: {
117
150
  status: 200,
118
151
  maintaining: false,
119
- message: /* @__PURE__ */ __name(({ message, app }) => message || `application ${app == null ? void 0 : app.name} is running`, "message")
152
+ message: /* @__PURE__ */ __name(({ message, app }) => message || `application ${getAppName(app)} is running`, "message")
120
153
  },
121
154
  UNKNOWN_ERROR: {
122
155
  status: 500,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "2.0.0-alpha.54",
3
+ "version": "2.0.0-alpha.55",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "AGPL-3.0",
@@ -10,20 +10,20 @@
10
10
  "@koa/cors": "^5.0.0",
11
11
  "@koa/multer": "^3.1.0",
12
12
  "@koa/router": "^13.1.0",
13
- "@nocobase/acl": "2.0.0-alpha.54",
14
- "@nocobase/actions": "2.0.0-alpha.54",
15
- "@nocobase/auth": "2.0.0-alpha.54",
16
- "@nocobase/cache": "2.0.0-alpha.54",
17
- "@nocobase/data-source-manager": "2.0.0-alpha.54",
18
- "@nocobase/database": "2.0.0-alpha.54",
19
- "@nocobase/evaluators": "2.0.0-alpha.54",
20
- "@nocobase/lock-manager": "2.0.0-alpha.54",
21
- "@nocobase/logger": "2.0.0-alpha.54",
22
- "@nocobase/resourcer": "2.0.0-alpha.54",
23
- "@nocobase/sdk": "2.0.0-alpha.54",
24
- "@nocobase/snowflake-id": "2.0.0-alpha.54",
25
- "@nocobase/telemetry": "2.0.0-alpha.54",
26
- "@nocobase/utils": "2.0.0-alpha.54",
13
+ "@nocobase/acl": "2.0.0-alpha.55",
14
+ "@nocobase/actions": "2.0.0-alpha.55",
15
+ "@nocobase/auth": "2.0.0-alpha.55",
16
+ "@nocobase/cache": "2.0.0-alpha.55",
17
+ "@nocobase/data-source-manager": "2.0.0-alpha.55",
18
+ "@nocobase/database": "2.0.0-alpha.55",
19
+ "@nocobase/evaluators": "2.0.0-alpha.55",
20
+ "@nocobase/lock-manager": "2.0.0-alpha.55",
21
+ "@nocobase/logger": "2.0.0-alpha.55",
22
+ "@nocobase/resourcer": "2.0.0-alpha.55",
23
+ "@nocobase/sdk": "2.0.0-alpha.55",
24
+ "@nocobase/snowflake-id": "2.0.0-alpha.55",
25
+ "@nocobase/telemetry": "2.0.0-alpha.55",
26
+ "@nocobase/utils": "2.0.0-alpha.55",
27
27
  "@types/decompress": "4.2.7",
28
28
  "@types/ini": "^1.3.31",
29
29
  "@types/koa-send": "^4.1.3",
@@ -60,5 +60,5 @@
60
60
  "@types/serve-handler": "^6.1.1",
61
61
  "@types/ws": "^8.5.5"
62
62
  },
63
- "gitHead": "68c84deaabba0ebec7407bf7245376b8d843449c"
63
+ "gitHead": "7e65ad6b6e4e76a51f82c69b04b563fbcc7e1c25"
64
64
  }