@coffer-org/server 1.12.0 → 1.13.0
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/dist/index.js +21 -1
- package/dist/plugin-updates.d.ts +5 -0
- package/dist/plugin-updates.js +10 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ import { registerMcpHttp } from "./mcp-http.js";
|
|
|
24
24
|
import { registerOAuthApi } from "./oauth-api.js";
|
|
25
25
|
import { baseUrl } from "./public-url.js";
|
|
26
26
|
import { discoverPluginAssets, discoverRuntime } from "./plugin-discovery.js";
|
|
27
|
-
import { checkLatestVersion, resolveUpdateTarget, resolveAllUpdateTargets, resolveRuntimeTarget, runNpmInstall, } from "./plugin-updates.js";
|
|
27
|
+
import { checkLatestVersion, resolveUpdateTarget, resolveAllUpdateTargets, resolveBaseTargets, resolveRuntimeTarget, runNpmInstall, } from "./plugin-updates.js";
|
|
28
28
|
import { buildClientSchema } from "./schema-api.js";
|
|
29
29
|
import { recordList, recordGet, recordCreate, recordUpdate, recordDelete, rowMatch, UnknownTypeError } from "./records-api.js";
|
|
30
30
|
import { maskTree, preserveTree } from "./field-masking.js";
|
|
@@ -294,6 +294,26 @@ app.post('/api/plugins/update-all', async (req, reply) => {
|
|
|
294
294
|
reply.send({ ok: true, updated });
|
|
295
295
|
setTimeout(() => process.exit(0), 500);
|
|
296
296
|
});
|
|
297
|
+
app.post('/api/system/update', async (req, reply) => {
|
|
298
|
+
if (!requireAdmin(req, reply))
|
|
299
|
+
return;
|
|
300
|
+
const assets = await discoverPluginAssets();
|
|
301
|
+
const runtime = await discoverRuntime();
|
|
302
|
+
const core = assets.find((a) => a.id === 'core');
|
|
303
|
+
const [coreLatest, runtimeLatest] = await Promise.all([
|
|
304
|
+
core && !core.local ? checkLatestVersion(core.packageName) : Promise.resolve(null),
|
|
305
|
+
runtime && !runtime.local ? checkLatestVersion(runtime.packageName) : Promise.resolve(null),
|
|
306
|
+
]);
|
|
307
|
+
const targets = resolveBaseTargets(assets, runtime, coreLatest, runtimeLatest);
|
|
308
|
+
if (targets.length === 0)
|
|
309
|
+
return reply.code(400).send({ error: 'no_update_available' });
|
|
310
|
+
const result = await runNpmInstall(targets.map((t) => `${t.packageName}@${t.to}`), process.cwd());
|
|
311
|
+
if (!result.ok) {
|
|
312
|
+
return reply.code(500).send({ error: 'install_failed', stderr: result.stderr });
|
|
313
|
+
}
|
|
314
|
+
reply.send({ ok: true, updated: targets.map(({ id, from, to }) => ({ id, from, to })) });
|
|
315
|
+
setTimeout(() => process.exit(0), 500);
|
|
316
|
+
});
|
|
297
317
|
app.get('/api/plugins/:id/settings', async (req, reply) => {
|
|
298
318
|
if (!requireAdmin(req, reply))
|
|
299
319
|
return;
|
package/dist/plugin-updates.d.ts
CHANGED
|
@@ -16,6 +16,11 @@ export interface AllUpdateTarget {
|
|
|
16
16
|
to: string;
|
|
17
17
|
}
|
|
18
18
|
export declare function resolveAllUpdateTargets(assets: PluginAssetRecord[], latestById: Map<string, string | null>): AllUpdateTarget[];
|
|
19
|
+
export declare function resolveBaseTargets(assets: PluginAssetRecord[], runtime: {
|
|
20
|
+
packageName: string;
|
|
21
|
+
installedVersion: string;
|
|
22
|
+
local: boolean;
|
|
23
|
+
} | null, coreLatest: string | null, runtimeLatest: string | null): AllUpdateTarget[];
|
|
19
24
|
export interface RuntimeUpdateTarget {
|
|
20
25
|
packageName: string;
|
|
21
26
|
from: string;
|
package/dist/plugin-updates.js
CHANGED
|
@@ -49,6 +49,16 @@ export function resolveAllUpdateTargets(assets, latestById) {
|
|
|
49
49
|
return [{ id: rec.id, packageName: rec.packageName, from: rec.version, to: latest }];
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
+
export function resolveBaseTargets(assets, runtime, coreLatest, runtimeLatest) {
|
|
53
|
+
const core = assets.find((a) => a.id === 'core');
|
|
54
|
+
const rt = resolveRuntimeTarget(runtime, runtimeLatest);
|
|
55
|
+
return [
|
|
56
|
+
...(core && !core.local && coreLatest && coreLatest !== core.version
|
|
57
|
+
? [{ id: 'core', packageName: core.packageName, from: core.version, to: coreLatest }]
|
|
58
|
+
: []),
|
|
59
|
+
...(rt ? [{ id: 'runtime', packageName: rt.packageName, from: rt.from, to: rt.to }] : []),
|
|
60
|
+
];
|
|
61
|
+
}
|
|
52
62
|
export function resolveRuntimeTarget(runtime, latestVersion) {
|
|
53
63
|
if (!runtime || runtime.local)
|
|
54
64
|
return null;
|