@nocobase/server 2.0.0-alpha.53 → 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.
- package/lib/application.js +5 -1
- package/lib/gateway/errors.js +47 -14
- package/lib/plugin-manager/deps.js +1 -1
- package/lib/snowflake-id-field.d.ts +2 -1
- package/lib/snowflake-id-field.js +2 -2
- package/package.json +16 -16
package/lib/application.js
CHANGED
|
@@ -949,6 +949,11 @@ const _Application = class _Application extends import_koa.default {
|
|
|
949
949
|
name: "auth",
|
|
950
950
|
actions: import_auth.actions
|
|
951
951
|
});
|
|
952
|
+
this._dataSourceManager.beforeAddDataSource((dataSource) => {
|
|
953
|
+
if (dataSource.collectionManager instanceof import_data_source_manager.SequelizeCollectionManager) {
|
|
954
|
+
(0, import_snowflake_id_field.setupSnowflakeIdField)(this, dataSource.collectionManager.db);
|
|
955
|
+
}
|
|
956
|
+
});
|
|
952
957
|
this._dataSourceManager.afterAddDataSource((dataSource) => {
|
|
953
958
|
if (dataSource.collectionManager instanceof import_data_source_manager.SequelizeCollectionManager) {
|
|
954
959
|
for (const [actionName, actionParams] of Object.entries(import_available_action.availableActions)) {
|
|
@@ -990,7 +995,6 @@ const _Application = class _Application extends import_koa.default {
|
|
|
990
995
|
app: this
|
|
991
996
|
});
|
|
992
997
|
this.dataSourceManager.dataSources.set("main", mainDataSourceInstance);
|
|
993
|
-
(0, import_snowflake_id_field.setupSnowflakeIdField)(this);
|
|
994
998
|
}
|
|
995
999
|
createDatabase(options) {
|
|
996
1000
|
const logging = /* @__PURE__ */ __name((...args) => {
|
package/lib/gateway/errors.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
68
|
-
|
|
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 }) =>
|
|
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
|
|
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
|
|
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 }) =>
|
|
102
|
-
|
|
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 }) =>
|
|
108
|
-
|
|
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 }) =>
|
|
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
|
|
152
|
+
message: /* @__PURE__ */ __name(({ message, app }) => message || `application ${getAppName(app)} is running`, "message")
|
|
120
153
|
},
|
|
121
154
|
UNKNOWN_ERROR: {
|
|
122
155
|
status: 500,
|
|
@@ -6,5 +6,6 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
import { Database } from '@nocobase/database';
|
|
9
10
|
import Application from './application';
|
|
10
|
-
export declare function setupSnowflakeIdField(app: Application): void;
|
|
11
|
+
export declare function setupSnowflakeIdField(app: Application, db: Database): void;
|
|
@@ -31,13 +31,13 @@ __export(snowflake_id_field_exports, {
|
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(snowflake_id_field_exports);
|
|
33
33
|
var import_database = require("@nocobase/database");
|
|
34
|
-
function setupSnowflakeIdField(app) {
|
|
34
|
+
function setupSnowflakeIdField(app, db) {
|
|
35
35
|
const _SnowflakeIdField = class _SnowflakeIdField extends import_database.SnowflakeIdField {
|
|
36
36
|
};
|
|
37
37
|
__name(_SnowflakeIdField, "SnowflakeIdField");
|
|
38
38
|
let SnowflakeIdField = _SnowflakeIdField;
|
|
39
39
|
SnowflakeIdField.setApp(app);
|
|
40
|
-
|
|
40
|
+
db.registerFieldTypes({
|
|
41
41
|
snowflakeId: SnowflakeIdField
|
|
42
42
|
});
|
|
43
43
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
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.
|
|
14
|
-
"@nocobase/actions": "2.0.0-alpha.
|
|
15
|
-
"@nocobase/auth": "2.0.0-alpha.
|
|
16
|
-
"@nocobase/cache": "2.0.0-alpha.
|
|
17
|
-
"@nocobase/data-source-manager": "2.0.0-alpha.
|
|
18
|
-
"@nocobase/database": "2.0.0-alpha.
|
|
19
|
-
"@nocobase/evaluators": "2.0.0-alpha.
|
|
20
|
-
"@nocobase/lock-manager": "2.0.0-alpha.
|
|
21
|
-
"@nocobase/logger": "2.0.0-alpha.
|
|
22
|
-
"@nocobase/resourcer": "2.0.0-alpha.
|
|
23
|
-
"@nocobase/sdk": "2.0.0-alpha.
|
|
24
|
-
"@nocobase/snowflake-id": "2.0.0-alpha.
|
|
25
|
-
"@nocobase/telemetry": "2.0.0-alpha.
|
|
26
|
-
"@nocobase/utils": "2.0.0-alpha.
|
|
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": "
|
|
63
|
+
"gitHead": "7e65ad6b6e4e76a51f82c69b04b563fbcc7e1c25"
|
|
64
64
|
}
|