@nocobase/server 2.1.0-alpha.10 → 2.1.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/gateway/utils.js +5 -0
- package/lib/plugin-manager/options/resource.d.ts +10 -0
- package/lib/plugin-manager/options/resource.js +87 -51
- package/lib/plugin-manager/plugin-manager.js +1 -0
- package/lib/plugin.js +27 -0
- package/lib/pub-sub-manager/pub-sub-manager.js +1 -1
- package/package.json +17 -17
package/lib/gateway/utils.js
CHANGED
|
@@ -57,6 +57,11 @@ function rewriteV2AssetPublicPath(html, assetPublicPath) {
|
|
|
57
57
|
}
|
|
58
58
|
__name(rewriteV2AssetPublicPath, "rewriteV2AssetPublicPath");
|
|
59
59
|
function injectRuntimeScript(html, runtimeScript) {
|
|
60
|
+
const browserCheckerScriptMatch = html.match(/<script\b[^>]*browser-checker\.js[^>]*><\/script>/i);
|
|
61
|
+
if (browserCheckerScriptMatch == null ? void 0 : browserCheckerScriptMatch[0]) {
|
|
62
|
+
return html.replace(browserCheckerScriptMatch[0], `${runtimeScript}
|
|
63
|
+
${browserCheckerScriptMatch[0]}`);
|
|
64
|
+
}
|
|
60
65
|
const moduleScriptMatch = html.match(/<script\b[^>]*type=["']module["'][^>]*>/i);
|
|
61
66
|
if (moduleScriptMatch == null ? void 0 : moduleScriptMatch[0]) {
|
|
62
67
|
return html.replace(moduleScriptMatch[0], `${runtimeScript}
|
|
@@ -6,6 +6,15 @@
|
|
|
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
|
+
export type PluginClientLane = 'client' | 'client-v2';
|
|
10
|
+
export declare class PackageUrls {
|
|
11
|
+
static items: Record<string, string | undefined>;
|
|
12
|
+
static clear(): void;
|
|
13
|
+
static getCacheKey(packageName: string, lane: PluginClientLane): string;
|
|
14
|
+
static get(packageName: string, lane?: PluginClientLane): Promise<string>;
|
|
15
|
+
static hasClientEntry(packageName: string, lane: PluginClientLane): Promise<boolean>;
|
|
16
|
+
static fetch(packageName: string, lane?: PluginClientLane): Promise<string>;
|
|
17
|
+
}
|
|
9
18
|
declare const _default: {
|
|
10
19
|
name: string;
|
|
11
20
|
actions: {
|
|
@@ -17,6 +26,7 @@ declare const _default: {
|
|
|
17
26
|
remove(ctx: any, next: any): Promise<void>;
|
|
18
27
|
list(ctx: any, next: any): Promise<void>;
|
|
19
28
|
listEnabled(ctx: any, next: any): Promise<void>;
|
|
29
|
+
listEnabledV2(ctx: any, next: any): Promise<void>;
|
|
20
30
|
get(ctx: any, next: any): Promise<void>;
|
|
21
31
|
};
|
|
22
32
|
};
|
|
@@ -39,6 +39,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
39
39
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
40
40
|
var resource_exports = {};
|
|
41
41
|
__export(resource_exports, {
|
|
42
|
+
PackageUrls: () => PackageUrls,
|
|
42
43
|
default: () => resource_default
|
|
43
44
|
});
|
|
44
45
|
module.exports = __toCommonJS(resource_exports);
|
|
@@ -48,46 +49,95 @@ var import_fs_extra = __toESM(require("fs-extra"));
|
|
|
48
49
|
var import_path = __toESM(require("path"));
|
|
49
50
|
var import_crypto = __toESM(require("crypto"));
|
|
50
51
|
var import_package = __toESM(require("../../../package.json"));
|
|
52
|
+
const PLUGIN_CLIENT_ENTRY_FILES = {
|
|
53
|
+
client: "dist/client/index.js",
|
|
54
|
+
"client-v2": "dist/client-v2/index.js"
|
|
55
|
+
};
|
|
56
|
+
const PLUGIN_CLIENT_MARKER_FILES = {
|
|
57
|
+
client: "client.js",
|
|
58
|
+
"client-v2": "client-v2.js"
|
|
59
|
+
};
|
|
51
60
|
const _PackageUrls = class _PackageUrls {
|
|
52
|
-
static
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
static clear() {
|
|
62
|
+
this.items = {};
|
|
63
|
+
}
|
|
64
|
+
static getCacheKey(packageName, lane) {
|
|
65
|
+
return `${lane}:${packageName}`;
|
|
66
|
+
}
|
|
67
|
+
static async get(packageName, lane = "client") {
|
|
68
|
+
const cacheKey = this.getCacheKey(packageName, lane);
|
|
69
|
+
if (!this.items[cacheKey]) {
|
|
70
|
+
this.items[cacheKey] = await this.fetch(packageName, lane);
|
|
55
71
|
}
|
|
56
|
-
return this.items[
|
|
72
|
+
return this.items[cacheKey];
|
|
57
73
|
}
|
|
58
|
-
static async
|
|
59
|
-
const PLUGIN_CLIENT_ENTRY_FILE = "dist/client/index.js";
|
|
74
|
+
static async hasClientEntry(packageName, lane) {
|
|
60
75
|
const pkgPath = import_path.default.resolve(process.env.NODE_MODULES_PATH, packageName);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
if (!await import_fs_extra.default.exists(pkgPath)) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
return await import_fs_extra.default.exists(import_path.default.resolve(pkgPath, PLUGIN_CLIENT_MARKER_FILES[lane]));
|
|
80
|
+
}
|
|
81
|
+
static async fetch(packageName, lane = "client") {
|
|
82
|
+
const pluginClientEntryFile = PLUGIN_CLIENT_ENTRY_FILES[lane];
|
|
83
|
+
const pkgPath = import_path.default.resolve(process.env.NODE_MODULES_PATH, packageName);
|
|
84
|
+
const pkgExists = await import_fs_extra.default.exists(pkgPath);
|
|
85
|
+
if (!pkgExists) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
let t = "";
|
|
89
|
+
const dist = import_path.default.resolve(pkgPath, pluginClientEntryFile);
|
|
90
|
+
const distExists = await import_fs_extra.default.exists(dist);
|
|
91
|
+
if (distExists) {
|
|
92
|
+
const fsState = await import_fs_extra.default.stat(dist);
|
|
93
|
+
const appKey = process.env.APP_KEY || "";
|
|
94
|
+
let version = "";
|
|
95
|
+
try {
|
|
96
|
+
const pkgJson = await import_fs_extra.default.readJson(import_path.default.resolve(pkgPath, "package.json"));
|
|
97
|
+
if (pkgJson && typeof pkgJson.version === "string") {
|
|
98
|
+
version = pkgJson.version;
|
|
76
99
|
}
|
|
77
|
-
|
|
78
|
-
const salt = process.env.PLUGIN_URL_HASH_SALT || "";
|
|
79
|
-
const hash = import_crypto.default.createHash("sha256").update(fsState.mtime.getTime() + appKey + version + appVersion + salt).digest("hex").slice(0, 8);
|
|
80
|
-
t = `?hash=${hash}`;
|
|
100
|
+
} catch (error) {
|
|
81
101
|
}
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
|
|
102
|
+
const appVersion = import_package.default.version;
|
|
103
|
+
const salt = process.env.PLUGIN_URL_HASH_SALT || "";
|
|
104
|
+
const hash = import_crypto.default.createHash("sha256").update(fsState.mtime.getTime() + appKey + version + appVersion + salt).digest("hex").slice(0, 8);
|
|
105
|
+
t = `?hash=${hash}`;
|
|
85
106
|
}
|
|
107
|
+
const cdnBaseUrl = process.env.CDN_BASE_URL.replace(/\/+$/, "");
|
|
108
|
+
const url = `${cdnBaseUrl}${"/static/plugins/"}${packageName}/${pluginClientEntryFile}${t}`;
|
|
109
|
+
return url;
|
|
86
110
|
}
|
|
87
111
|
};
|
|
88
112
|
__name(_PackageUrls, "PackageUrls");
|
|
89
113
|
__publicField(_PackageUrls, "items", {});
|
|
90
114
|
let PackageUrls = _PackageUrls;
|
|
115
|
+
async function listEnabledPlugins(ctx, lane = "client") {
|
|
116
|
+
const pm = ctx.db.getRepository("applicationPlugins");
|
|
117
|
+
const items = await pm.find({
|
|
118
|
+
filter: {
|
|
119
|
+
enabled: true
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
const arr = [];
|
|
123
|
+
for (const item of items) {
|
|
124
|
+
if (lane === "client-v2" && !await PackageUrls.hasClientEntry(item.packageName, lane)) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const url = await PackageUrls.get(item.packageName, lane);
|
|
128
|
+
const { name, packageName, options } = item.toJSON();
|
|
129
|
+
if (url) {
|
|
130
|
+
arr.push({
|
|
131
|
+
name,
|
|
132
|
+
packageName,
|
|
133
|
+
options,
|
|
134
|
+
url
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return arr;
|
|
139
|
+
}
|
|
140
|
+
__name(listEnabledPlugins, "listEnabledPlugins");
|
|
91
141
|
var resource_default = {
|
|
92
142
|
name: "pm",
|
|
93
143
|
actions: {
|
|
@@ -197,29 +247,11 @@ var resource_default = {
|
|
|
197
247
|
await next();
|
|
198
248
|
},
|
|
199
249
|
async listEnabled(ctx, next) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
const arr = [];
|
|
208
|
-
for (const item of items) {
|
|
209
|
-
const url = await PackageUrls.get(item.packageName);
|
|
210
|
-
const { name, packageName, options } = item.toJSON();
|
|
211
|
-
if (url) {
|
|
212
|
-
arr.push({
|
|
213
|
-
name,
|
|
214
|
-
packageName,
|
|
215
|
-
options,
|
|
216
|
-
url
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return arr;
|
|
221
|
-
}, "toArr");
|
|
222
|
-
ctx.body = await toArr();
|
|
250
|
+
ctx.body = await listEnabledPlugins(ctx, "client");
|
|
251
|
+
await next();
|
|
252
|
+
},
|
|
253
|
+
async listEnabledV2(ctx, next) {
|
|
254
|
+
ctx.body = await listEnabledPlugins(ctx, "client-v2");
|
|
223
255
|
await next();
|
|
224
256
|
},
|
|
225
257
|
async get(ctx, next) {
|
|
@@ -235,3 +267,7 @@ var resource_default = {
|
|
|
235
267
|
}
|
|
236
268
|
}
|
|
237
269
|
};
|
|
270
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
271
|
+
0 && (module.exports = {
|
|
272
|
+
PackageUrls
|
|
273
|
+
});
|
|
@@ -90,6 +90,7 @@ const _PluginManager = class _PluginManager {
|
|
|
90
90
|
this._repository.setPluginManager(this);
|
|
91
91
|
this.app.resourcer.define(import_resource.default);
|
|
92
92
|
this.app.acl.allow("pm", "listEnabled", "public");
|
|
93
|
+
this.app.acl.allow("pm", "listEnabledV2", "public");
|
|
93
94
|
this.app.acl.registerSnippet({
|
|
94
95
|
name: "pm",
|
|
95
96
|
actions: ["pm:*"]
|
package/lib/plugin.js
CHANGED
|
@@ -213,6 +213,33 @@ const _Plugin = class _Plugin {
|
|
|
213
213
|
log: this.log
|
|
214
214
|
});
|
|
215
215
|
await toolsLoader.load();
|
|
216
|
+
const mcpLoader = new import_ai.MCPLoader(this.ai, {
|
|
217
|
+
scan: {
|
|
218
|
+
basePath,
|
|
219
|
+
pattern: ["mcp/*.ts", "mcp/*.js", "!mcp/*.d.ts"]
|
|
220
|
+
},
|
|
221
|
+
log: this.log
|
|
222
|
+
});
|
|
223
|
+
await mcpLoader.load();
|
|
224
|
+
const skillsLoader = new import_ai.SkillsLoader(this.ai, {
|
|
225
|
+
scan: { basePath, pattern: ["**/skills/**/SKILLS.md"] },
|
|
226
|
+
log: this.log
|
|
227
|
+
});
|
|
228
|
+
await skillsLoader.load();
|
|
229
|
+
const employeeLoader = new import_ai.AIEmployeeLoader(this.ai, {
|
|
230
|
+
scan: {
|
|
231
|
+
basePath,
|
|
232
|
+
pattern: [
|
|
233
|
+
"**/ai-employees/*.ts",
|
|
234
|
+
"**/ai-employees/*/index.ts",
|
|
235
|
+
"**/ai-employees/*.js",
|
|
236
|
+
"**/ai-employees/*/index.js",
|
|
237
|
+
"!**/ai-employees/**/*.d.ts"
|
|
238
|
+
]
|
|
239
|
+
},
|
|
240
|
+
log: this.log
|
|
241
|
+
});
|
|
242
|
+
await employeeLoader.load();
|
|
216
243
|
}
|
|
217
244
|
/**
|
|
218
245
|
* @deprecated
|
|
@@ -38,7 +38,7 @@ const createPubSubManager = /* @__PURE__ */ __name((app, options) => {
|
|
|
38
38
|
app.on("afterStart", async () => {
|
|
39
39
|
await pubSubManager.connect();
|
|
40
40
|
});
|
|
41
|
-
app.on("
|
|
41
|
+
app.on("beforeStop", async () => {
|
|
42
42
|
await pubSubManager.close();
|
|
43
43
|
});
|
|
44
44
|
return pubSubManager;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.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": "2.1.0-alpha.
|
|
14
|
-
"@nocobase/actions": "2.1.0-alpha.
|
|
15
|
-
"@nocobase/ai": "2.1.0-alpha.
|
|
16
|
-
"@nocobase/auth": "2.1.0-alpha.
|
|
17
|
-
"@nocobase/cache": "2.1.0-alpha.
|
|
18
|
-
"@nocobase/data-source-manager": "2.1.0-alpha.
|
|
19
|
-
"@nocobase/database": "2.1.0-alpha.
|
|
20
|
-
"@nocobase/evaluators": "2.1.0-alpha.
|
|
21
|
-
"@nocobase/lock-manager": "2.1.0-alpha.
|
|
22
|
-
"@nocobase/logger": "2.1.0-alpha.
|
|
23
|
-
"@nocobase/resourcer": "2.1.0-alpha.
|
|
24
|
-
"@nocobase/sdk": "2.1.0-alpha.
|
|
25
|
-
"@nocobase/snowflake-id": "2.1.0-alpha.
|
|
26
|
-
"@nocobase/telemetry": "2.1.0-alpha.
|
|
27
|
-
"@nocobase/utils": "2.1.0-alpha.
|
|
13
|
+
"@nocobase/acl": "2.1.0-alpha.11",
|
|
14
|
+
"@nocobase/actions": "2.1.0-alpha.11",
|
|
15
|
+
"@nocobase/ai": "2.1.0-alpha.11",
|
|
16
|
+
"@nocobase/auth": "2.1.0-alpha.11",
|
|
17
|
+
"@nocobase/cache": "2.1.0-alpha.11",
|
|
18
|
+
"@nocobase/data-source-manager": "2.1.0-alpha.11",
|
|
19
|
+
"@nocobase/database": "2.1.0-alpha.11",
|
|
20
|
+
"@nocobase/evaluators": "2.1.0-alpha.11",
|
|
21
|
+
"@nocobase/lock-manager": "2.1.0-alpha.11",
|
|
22
|
+
"@nocobase/logger": "2.1.0-alpha.11",
|
|
23
|
+
"@nocobase/resourcer": "2.1.0-alpha.11",
|
|
24
|
+
"@nocobase/sdk": "2.1.0-alpha.11",
|
|
25
|
+
"@nocobase/snowflake-id": "2.1.0-alpha.11",
|
|
26
|
+
"@nocobase/telemetry": "2.1.0-alpha.11",
|
|
27
|
+
"@nocobase/utils": "2.1.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": "bb96d633a6371afb586072ff516bd0613c757db0"
|
|
65
65
|
}
|