@nocobase/server 3.0.0-alpha.1 → 3.0.0-alpha.11
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/event-queue.js +3 -1
- package/lib/gateway/index.d.ts +1 -0
- package/lib/gateway/index.js +29 -10
- package/lib/helper.js +4 -2
- package/package.json +17 -17
package/lib/event-queue.js
CHANGED
|
@@ -84,7 +84,9 @@ const _MemoryEventQueueAdapter = class _MemoryEventQueueAdapter {
|
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
86
|
const reading = this.reading.get(channel) || [];
|
|
87
|
-
const
|
|
87
|
+
const queue = this.queues.get(channel);
|
|
88
|
+
const concurrency = event.concurrency ?? QUEUE_DEFAULT_CONCURRENCY;
|
|
89
|
+
const count = concurrency <= 0 ? (queue == null ? void 0 : queue.length) || 0 : concurrency - reading.length;
|
|
88
90
|
if (count <= 0) {
|
|
89
91
|
return;
|
|
90
92
|
}
|
package/lib/gateway/index.d.ts
CHANGED
|
@@ -89,6 +89,7 @@ export declare class Gateway extends EventEmitter {
|
|
|
89
89
|
private resolveLegacyV2SettingsRedirect;
|
|
90
90
|
private getPortalRootPublicPath;
|
|
91
91
|
private getPortalAppPublicPath;
|
|
92
|
+
private resolvePortalRootEntryRedirect;
|
|
92
93
|
private getPortalMatch;
|
|
93
94
|
private isPortalIndexRequest;
|
|
94
95
|
private getPortalDistRoot;
|
package/lib/gateway/index.js
CHANGED
|
@@ -358,10 +358,6 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
358
358
|
from: "/admin/settings/mail/oauth2",
|
|
359
359
|
to: "/admin/settings/mail/oauth2"
|
|
360
360
|
},
|
|
361
|
-
{
|
|
362
|
-
from: "/admin/ai/knowledge-base/detail",
|
|
363
|
-
to: "/settings/ai/knowledge-base/detail"
|
|
364
|
-
},
|
|
365
361
|
{
|
|
366
362
|
from: "/admin/workflow/executions",
|
|
367
363
|
to: "/settings/workflow/executions"
|
|
@@ -394,6 +390,22 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
394
390
|
}
|
|
395
391
|
return `${this.getPortalRootPublicPath()}apps/${(0, import_utils3.normalizePortalAppName)(appName)}/`;
|
|
396
392
|
}
|
|
393
|
+
resolvePortalRootEntryRedirect(pathname) {
|
|
394
|
+
const portalRootPublicPath = this.getPortalRootPublicPath();
|
|
395
|
+
const v2PublicPath = this.getV2PublicPath();
|
|
396
|
+
if (v2PublicPath === portalRootPublicPath) {
|
|
397
|
+
return null;
|
|
398
|
+
}
|
|
399
|
+
if (pathname === portalRootPublicPath || pathname === portalRootPublicPath.slice(0, -1)) {
|
|
400
|
+
return v2PublicPath;
|
|
401
|
+
}
|
|
402
|
+
const portalAppsPublicPath = `${portalRootPublicPath}apps/`;
|
|
403
|
+
if (!pathname.startsWith(portalAppsPublicPath)) {
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
const match = /^([A-Za-z0-9_-]+)\/?$/.exec(pathname.slice(portalAppsPublicPath.length));
|
|
407
|
+
return match ? `${v2PublicPath}apps/${match[1]}/` : null;
|
|
408
|
+
}
|
|
397
409
|
getPortalMatch(pathname) {
|
|
398
410
|
const portalRootPublicPath = this.getPortalRootPublicPath();
|
|
399
411
|
if (!pathname.startsWith(portalRootPublicPath)) {
|
|
@@ -580,6 +592,13 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
580
592
|
res.end();
|
|
581
593
|
return;
|
|
582
594
|
}
|
|
595
|
+
const portalRootEntryRedirect = this.resolvePortalRootEntryRedirect(pathname);
|
|
596
|
+
if (portalRootEntryRedirect) {
|
|
597
|
+
res.statusCode = 302;
|
|
598
|
+
res.setHeader("Location", `${portalRootEntryRedirect}${search || ""}`);
|
|
599
|
+
res.end();
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
583
602
|
const supervisor = import_app_supervisor.AppSupervisor.getInstance();
|
|
584
603
|
let handleApp = "main";
|
|
585
604
|
try {
|
|
@@ -680,12 +699,6 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
680
699
|
return;
|
|
681
700
|
}
|
|
682
701
|
}
|
|
683
|
-
if (!pathname.startsWith(portalMatch.publicPath)) {
|
|
684
|
-
res.statusCode = 302;
|
|
685
|
-
res.setHeader("Location", `${portalMatch.publicPath}${search || ""}`);
|
|
686
|
-
res.end();
|
|
687
|
-
return;
|
|
688
|
-
}
|
|
689
702
|
const portalDistRoot = this.getPortalDistRoot(portalMatch);
|
|
690
703
|
const portalIndex = (0, import_path.resolve)(portalDistRoot, "index.html");
|
|
691
704
|
if (!import_fs.default.existsSync(portalIndex)) {
|
|
@@ -693,6 +706,12 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
693
706
|
res.end();
|
|
694
707
|
return;
|
|
695
708
|
}
|
|
709
|
+
if (!pathname.startsWith(portalMatch.publicPath)) {
|
|
710
|
+
res.statusCode = 302;
|
|
711
|
+
res.setHeader("Location", `${portalMatch.publicPath}${search || ""}`);
|
|
712
|
+
res.end();
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
696
715
|
if (this.isPortalIndexRequest(pathname, portalMatch.publicPath)) {
|
|
697
716
|
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
698
717
|
res.end(import_fs.default.readFileSync(portalIndex, "utf-8"));
|
package/lib/helper.js
CHANGED
|
@@ -112,7 +112,7 @@ function registerMiddlewares(app, options) {
|
|
|
112
112
|
app.use(
|
|
113
113
|
(0, import_cors.default)({
|
|
114
114
|
credentials: isWhitelistedCorsOrigin,
|
|
115
|
-
exposeHeaders: ["content-disposition"],
|
|
115
|
+
exposeHeaders: ["content-disposition", "x-new-token"],
|
|
116
116
|
origin: resolveCorsOrigin,
|
|
117
117
|
...options.cors
|
|
118
118
|
}),
|
|
@@ -138,6 +138,7 @@ function registerMiddlewares(app, options) {
|
|
|
138
138
|
}
|
|
139
139
|
app.use(/* @__PURE__ */ __name(async function getBearerToken(ctx, next) {
|
|
140
140
|
ctx.getBearerToken = () => {
|
|
141
|
+
var _a2;
|
|
141
142
|
const authorization = ctx.get("Authorization");
|
|
142
143
|
if (authorization) {
|
|
143
144
|
ctx.state.pendingAuthTokenSource = "authorization";
|
|
@@ -147,7 +148,8 @@ function registerMiddlewares(app, options) {
|
|
|
147
148
|
ctx.state.pendingAuthTokenSource = "query";
|
|
148
149
|
return ctx.query.token;
|
|
149
150
|
}
|
|
150
|
-
const
|
|
151
|
+
const canUseAuthCookie = Boolean((_a2 = ctx.state) == null ? void 0 : _a2.fileAccess) && ["GET", "HEAD"].includes(ctx.method);
|
|
152
|
+
const cookieToken = canUseAuthCookie ? ctx.cookies.get((0, import_utils.getAuthCookieName)("authToken", app.name)) : void 0;
|
|
151
153
|
ctx.state.pendingAuthTokenSource = cookieToken ? "cookie" : void 0;
|
|
152
154
|
return cookieToken;
|
|
153
155
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.11",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -10,21 +10,21 @@
|
|
|
10
10
|
"@koa/cors": "^5.0.0",
|
|
11
11
|
"@koa/multer": "^3.1.0",
|
|
12
12
|
"@koa/router": "^13.1.0",
|
|
13
|
-
"@nocobase/acl": "3.0.0-alpha.
|
|
14
|
-
"@nocobase/actions": "3.0.0-alpha.
|
|
15
|
-
"@nocobase/ai": "3.0.0-alpha.
|
|
16
|
-
"@nocobase/auth": "3.0.0-alpha.
|
|
17
|
-
"@nocobase/cache": "3.0.0-alpha.
|
|
18
|
-
"@nocobase/data-source-manager": "3.0.0-alpha.
|
|
19
|
-
"@nocobase/database": "3.0.0-alpha.
|
|
20
|
-
"@nocobase/evaluators": "3.0.0-alpha.
|
|
21
|
-
"@nocobase/lock-manager": "3.0.0-alpha.
|
|
22
|
-
"@nocobase/logger": "3.0.0-alpha.
|
|
23
|
-
"@nocobase/resourcer": "3.0.0-alpha.
|
|
24
|
-
"@nocobase/sdk": "3.0.0-alpha.
|
|
25
|
-
"@nocobase/snowflake-id": "3.0.0-alpha.
|
|
26
|
-
"@nocobase/telemetry": "3.0.0-alpha.
|
|
27
|
-
"@nocobase/utils": "3.0.0-alpha.
|
|
13
|
+
"@nocobase/acl": "3.0.0-alpha.11",
|
|
14
|
+
"@nocobase/actions": "3.0.0-alpha.11",
|
|
15
|
+
"@nocobase/ai": "3.0.0-alpha.11",
|
|
16
|
+
"@nocobase/auth": "3.0.0-alpha.11",
|
|
17
|
+
"@nocobase/cache": "3.0.0-alpha.11",
|
|
18
|
+
"@nocobase/data-source-manager": "3.0.0-alpha.11",
|
|
19
|
+
"@nocobase/database": "3.0.0-alpha.11",
|
|
20
|
+
"@nocobase/evaluators": "3.0.0-alpha.11",
|
|
21
|
+
"@nocobase/lock-manager": "3.0.0-alpha.11",
|
|
22
|
+
"@nocobase/logger": "3.0.0-alpha.11",
|
|
23
|
+
"@nocobase/resourcer": "3.0.0-alpha.11",
|
|
24
|
+
"@nocobase/sdk": "3.0.0-alpha.11",
|
|
25
|
+
"@nocobase/snowflake-id": "3.0.0-alpha.11",
|
|
26
|
+
"@nocobase/telemetry": "3.0.0-alpha.11",
|
|
27
|
+
"@nocobase/utils": "3.0.0-alpha.11",
|
|
28
28
|
"@types/decompress": "4.2.7",
|
|
29
29
|
"@types/ini": "^1.3.31",
|
|
30
30
|
"@types/koa-send": "^4.1.3",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"@types/serve-handler": "^6.1.1",
|
|
62
62
|
"@types/ws": "^8.5.5"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "03574f3a2d10b1ed8469dc7405aa0c4696d6d1d1"
|
|
65
65
|
}
|