@nocobase/server 1.9.0-beta.9 → 1.9.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/lib/application.js +1 -1
- package/lib/gateway/index.d.ts +2 -0
- package/lib/gateway/index.js +41 -0
- package/lib/locale/locale.js +1 -1
- package/lib/locale/resource.js +6 -9
- package/lib/migrations/20250902230900-update-primary-keys.js +1 -3
- package/lib/plugin-manager/plugin-manager.js +1 -1
- package/package.json +16 -16
package/lib/application.js
CHANGED
|
@@ -948,7 +948,7 @@ const _Application = class _Application extends import_koa.default {
|
|
|
948
948
|
}
|
|
949
949
|
}
|
|
950
950
|
});
|
|
951
|
-
this._dataSourceManager.use(this._authManager.middleware(), { tag: "auth" });
|
|
951
|
+
this._dataSourceManager.use(this._authManager.middleware(), { tag: "auth", before: "default" });
|
|
952
952
|
this._dataSourceManager.use(import_validate_filter_params.default, { tag: "validate-filter-params", before: ["auth"] });
|
|
953
953
|
this._dataSourceManager.use(import_middlewares.parseVariables, {
|
|
954
954
|
group: "parseVariables",
|
package/lib/gateway/index.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ export declare class Gateway extends EventEmitter {
|
|
|
47
47
|
private port;
|
|
48
48
|
private host;
|
|
49
49
|
private socketPath;
|
|
50
|
+
private terminating;
|
|
51
|
+
private onTerminate;
|
|
50
52
|
private constructor();
|
|
51
53
|
static getInstance(options?: any): Gateway;
|
|
52
54
|
static getIPCSocketClient(): Promise<false | IPCSocketClient>;
|
package/lib/gateway/index.js
CHANGED
|
@@ -86,10 +86,37 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
86
86
|
port = import_node_process.default.env.APP_PORT ? parseInt(import_node_process.default.env.APP_PORT) : null;
|
|
87
87
|
host = "0.0.0.0";
|
|
88
88
|
socketPath = (0, import_path.resolve)(import_node_process.default.cwd(), "storage", "gateway.sock");
|
|
89
|
+
terminating = false;
|
|
90
|
+
onTerminate = /* @__PURE__ */ __name(async (signal) => {
|
|
91
|
+
var _a;
|
|
92
|
+
if (this.terminating) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
this.terminating = true;
|
|
96
|
+
const supervisor = import_app_supervisor.AppSupervisor.getInstance();
|
|
97
|
+
const apps = Object.values(supervisor.apps || {});
|
|
98
|
+
try {
|
|
99
|
+
for (const app of apps) {
|
|
100
|
+
try {
|
|
101
|
+
await app.destroy({ signal });
|
|
102
|
+
} catch (error) {
|
|
103
|
+
const logger = (app == null ? void 0 : app.log) ?? console;
|
|
104
|
+
(_a = logger.error) == null ? void 0 : _a.call(logger, error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
await supervisor.destroy();
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error("Failed to shutdown applications gracefully", error);
|
|
110
|
+
} finally {
|
|
111
|
+
this.destroy();
|
|
112
|
+
}
|
|
113
|
+
}, "onTerminate");
|
|
89
114
|
constructor() {
|
|
90
115
|
super();
|
|
91
116
|
this.reset();
|
|
92
117
|
this.socketPath = getSocketPath();
|
|
118
|
+
import_node_process.default.once("SIGTERM", this.onTerminate);
|
|
119
|
+
import_node_process.default.once("SIGINT", this.onTerminate);
|
|
93
120
|
}
|
|
94
121
|
static getInstance(options = {}) {
|
|
95
122
|
if (!_Gateway.instance) {
|
|
@@ -106,6 +133,8 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
106
133
|
}
|
|
107
134
|
}
|
|
108
135
|
destroy() {
|
|
136
|
+
import_node_process.default.off("SIGTERM", this.onTerminate);
|
|
137
|
+
import_node_process.default.off("SIGINT", this.onTerminate);
|
|
109
138
|
this.reset();
|
|
110
139
|
_Gateway.instance = null;
|
|
111
140
|
}
|
|
@@ -137,6 +166,10 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
137
166
|
this.ipcSocketServer.close();
|
|
138
167
|
this.ipcSocketServer = null;
|
|
139
168
|
}
|
|
169
|
+
if (this.wsServer) {
|
|
170
|
+
this.wsServer.close();
|
|
171
|
+
this.wsServer = null;
|
|
172
|
+
}
|
|
140
173
|
}
|
|
141
174
|
addAppSelectorMiddleware(middleware, options) {
|
|
142
175
|
if (this.selectorMiddlewares.nodes.some((existingFunc) => existingFunc.toString() === middleware.toString())) {
|
|
@@ -169,7 +202,15 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
169
202
|
res.end(JSON.stringify({ error }));
|
|
170
203
|
}
|
|
171
204
|
responseErrorWithCode(code, res, options) {
|
|
205
|
+
const log = this.getLogger(options.appName, res);
|
|
172
206
|
const error = (0, import_errors.applyErrorWithArgs)((0, import_errors.getErrorWithCode)(code), options);
|
|
207
|
+
log.error(error.message, {
|
|
208
|
+
method: "responseErrorWithCode",
|
|
209
|
+
code,
|
|
210
|
+
error,
|
|
211
|
+
statusCode: res.statusCode,
|
|
212
|
+
appName: options.appName
|
|
213
|
+
});
|
|
173
214
|
this.responseError(res, error);
|
|
174
215
|
}
|
|
175
216
|
async requestHandler(req, res) {
|
package/lib/locale/locale.js
CHANGED
|
@@ -138,7 +138,7 @@ const _Locale = class _Locale {
|
|
|
138
138
|
if (!packageName) {
|
|
139
139
|
continue;
|
|
140
140
|
}
|
|
141
|
-
const res = (0, import_resource.getResource)(packageName, lang);
|
|
141
|
+
const res = await (0, import_resource.getResource)(packageName, lang);
|
|
142
142
|
if (res) {
|
|
143
143
|
resources[packageName] = { ...res };
|
|
144
144
|
if (packageName.includes(import__.OFFICIAL_PLUGIN_PREFIX)) {
|
package/lib/locale/resource.js
CHANGED
|
@@ -40,7 +40,7 @@ __export(resource_exports, {
|
|
|
40
40
|
getResource: () => getResource
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(resource_exports);
|
|
43
|
-
var
|
|
43
|
+
var import_promises = __toESM(require("fs/promises"));
|
|
44
44
|
const arr2obj = /* @__PURE__ */ __name((items) => {
|
|
45
45
|
const obj = {};
|
|
46
46
|
for (const item of items) {
|
|
@@ -48,7 +48,7 @@ const arr2obj = /* @__PURE__ */ __name((items) => {
|
|
|
48
48
|
}
|
|
49
49
|
return obj;
|
|
50
50
|
}, "arr2obj");
|
|
51
|
-
const getResource = /* @__PURE__ */ __name((packageName, lang, isPlugin = true) => {
|
|
51
|
+
const getResource = /* @__PURE__ */ __name(async (packageName, lang, isPlugin = true) => {
|
|
52
52
|
const resources = [];
|
|
53
53
|
const prefixes = [isPlugin ? "dist" : "lib"];
|
|
54
54
|
if (process.env.APP_ENV !== "production") {
|
|
@@ -63,13 +63,10 @@ const getResource = /* @__PURE__ */ __name((packageName, lang, isPlugin = true)
|
|
|
63
63
|
}
|
|
64
64
|
for (const prefix of prefixes) {
|
|
65
65
|
try {
|
|
66
|
-
const file = `${packageName}/${prefix}/locale/${lang}`;
|
|
66
|
+
const file = `${packageName}/${prefix}/locale/${lang}.json`;
|
|
67
67
|
const f = require.resolve(file);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
const resource = (0, import_utils.requireModule)(file);
|
|
72
|
-
resources.push(resource);
|
|
68
|
+
const resource = await import_promises.default.readFile(f, "utf8");
|
|
69
|
+
resources.push(JSON.parse(resource));
|
|
73
70
|
} catch (error) {
|
|
74
71
|
}
|
|
75
72
|
if (resources.length) {
|
|
@@ -77,7 +74,7 @@ const getResource = /* @__PURE__ */ __name((packageName, lang, isPlugin = true)
|
|
|
77
74
|
}
|
|
78
75
|
}
|
|
79
76
|
if (resources.length === 0 && lang.replace("-", "_") !== lang) {
|
|
80
|
-
return getResource(packageName, lang.replace("-", "_"));
|
|
77
|
+
return await getResource(packageName, lang.replace("-", "_"));
|
|
81
78
|
}
|
|
82
79
|
return arr2obj(resources);
|
|
83
80
|
}, "getResource");
|
|
@@ -82,9 +82,7 @@ const _update_primary_keys_default = class _update_primary_keys_default extends
|
|
|
82
82
|
} else {
|
|
83
83
|
await queryInterface.changeColumn(tableName, "id", {
|
|
84
84
|
type: import_sequelize.DataTypes.BIGINT,
|
|
85
|
-
|
|
86
|
-
allowNull: false,
|
|
87
|
-
autoIncrement: false
|
|
85
|
+
allowNull: false
|
|
88
86
|
});
|
|
89
87
|
}
|
|
90
88
|
}
|
|
@@ -90,7 +90,7 @@ const _PluginManager = class _PluginManager {
|
|
|
90
90
|
namespace: "core/pm",
|
|
91
91
|
directory: (0, import_path.resolve)(__dirname, "../migrations")
|
|
92
92
|
});
|
|
93
|
-
this.app.
|
|
93
|
+
this.app.resourceManager.use(import_middleware.uploadMiddleware, { tag: "upload", after: "acl" });
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
96
|
* @internal
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.1",
|
|
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": "1.9.
|
|
14
|
-
"@nocobase/actions": "1.9.
|
|
15
|
-
"@nocobase/auth": "1.9.
|
|
16
|
-
"@nocobase/cache": "1.9.
|
|
17
|
-
"@nocobase/data-source-manager": "1.9.
|
|
18
|
-
"@nocobase/database": "1.9.
|
|
19
|
-
"@nocobase/evaluators": "1.9.
|
|
20
|
-
"@nocobase/lock-manager": "1.9.
|
|
21
|
-
"@nocobase/logger": "1.9.
|
|
22
|
-
"@nocobase/resourcer": "1.9.
|
|
23
|
-
"@nocobase/sdk": "1.9.
|
|
24
|
-
"@nocobase/snowflake-id": "1.9.
|
|
25
|
-
"@nocobase/telemetry": "1.9.
|
|
26
|
-
"@nocobase/utils": "1.9.
|
|
13
|
+
"@nocobase/acl": "1.9.1",
|
|
14
|
+
"@nocobase/actions": "1.9.1",
|
|
15
|
+
"@nocobase/auth": "1.9.1",
|
|
16
|
+
"@nocobase/cache": "1.9.1",
|
|
17
|
+
"@nocobase/data-source-manager": "1.9.1",
|
|
18
|
+
"@nocobase/database": "1.9.1",
|
|
19
|
+
"@nocobase/evaluators": "1.9.1",
|
|
20
|
+
"@nocobase/lock-manager": "1.9.1",
|
|
21
|
+
"@nocobase/logger": "1.9.1",
|
|
22
|
+
"@nocobase/resourcer": "1.9.1",
|
|
23
|
+
"@nocobase/sdk": "1.9.1",
|
|
24
|
+
"@nocobase/snowflake-id": "1.9.1",
|
|
25
|
+
"@nocobase/telemetry": "1.9.1",
|
|
26
|
+
"@nocobase/utils": "1.9.1",
|
|
27
27
|
"@types/decompress": "4.2.7",
|
|
28
28
|
"@types/ini": "^1.3.31",
|
|
29
29
|
"@types/koa-send": "^4.1.3",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"@types/serve-handler": "^6.1.1",
|
|
60
60
|
"@types/ws": "^8.5.5"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "8a4face22c9be89c86484b97351e48f2ced3a834"
|
|
63
63
|
}
|