Add SCUM world query assets

This commit is contained in:
npc0-hue
2026-08-13 09:20:42 +08:00
parent bad09df3e2
commit e313081204
18 changed files with 471 additions and 3 deletions
+15 -2
View File
@@ -218,12 +218,22 @@ describe("plugin manifest validation", () => {
expect(JSON.stringify(manifest.scumLiveData).toLowerCase()).not.toMatch(/select\s+.+from|sqlite:\/\/|mysql:\/\/|password|credential|socket|hostpath/);
});
it("packages SCUM player read query assets with exact bounded result schemas", () => {
it("packages SCUM live read query assets with exact bounded result schemas", () => {
const pluginDir = path.join(pluginsRoot, "examples/scum-server-plugin");
const manifest = JSON.parse(fs.readFileSync(path.join(pluginDir, "manifest.json"), "utf8")) as GamePluginManifest & { scumLiveData: SCUMLiveDataManifestDeclaration };
const assetPaths = new Set(manifest.assetFiles?.map((file) => file.path) ?? []);
const queries = manifest.scumLiveData.sqliteQueries ?? [];
expect(queries.map((query) => query.key)).toEqual(["scum-players-read", "scum-player-details-read", "scum-player-economy-read", "scum-player-session-enrichment-read"]);
expect(queries.map((query) => query.key)).toEqual([
"scum-players-read",
"scum-player-details-read",
"scum-player-economy-read",
"scum-player-session-enrichment-read",
"scum-squads-read",
"scum-squad-members-read",
"scum-vehicles-read",
"scum-flags-read",
"scum-positions-read"
]);
for (const query of queries) {
expect(assetPaths.has(query.assetPath)).toBe(true);
@@ -235,6 +245,9 @@ describe("plugin manifest validation", () => {
expect(asset.safety).toMatchObject({ queryOnly: true, readOnlyConnection: true });
expect(asset.statement).toMatch(/^(WITH|SELECT)\b/i);
expect(asset.statement).not.toMatch(/;|\b(INSERT|UPDATE|DELETE|DROP|ALTER|CREATE|ATTACH)\b/i);
if (["scum-squads-read", "scum-squad-members-read", "scum-vehicles-read", "scum-flags-read"].includes(query.key)) {
expect(asset.statement).toContain("CAST(NULL");
}
for (const schemaRef of [query.parameterSchemaRef, query.resultSchemaRef]) {
expect(fs.existsSync(path.join(pluginDir, schemaRef))).toBe(true);