feat: plugins v1.5

This commit is contained in:
2026-04-29 01:14:30 +02:00
parent 6920f93b41
commit eabbc08896
59 changed files with 2197 additions and 352 deletions

View File

@@ -34,21 +34,6 @@ interface PluginEventDefinitionResponse {
};
}
interface PluginDataResponse {
record: {
key: string;
ownerId?: string;
pluginId: string;
schemaVersion: number;
scope: string;
value: unknown;
};
}
interface PluginDataListResponse {
records: PluginDataResponse['record'][];
}
interface PluginSnapshotResponse {
eventDefinitions: PluginEventDefinitionResponse['eventDefinition'][];
requirements: PluginRequirementResponse['requirement'][];
@@ -136,8 +121,8 @@ test.describe('Plugin support API', () => {
expect(snapshot.eventDefinitions.map((entry) => entry.eventName).sort()).toEqual([TEST_PLUGIN_P2P_EVENT, TEST_PLUGIN_RELAY_EVENT]);
});
await test.step('Plugin data API stores, lists, and deletes server scoped data', async () => {
const stored = await expectJson<PluginDataResponse>(await request.put(`${pluginsApi}/${TEST_PLUGIN_ID}/data/settings`, {
await test.step('Plugin data API refuses arbitrary server persistence', async () => {
const stored = await expectJson<{ errorCode: string }>(await request.put(`${pluginsApi}/${TEST_PLUGIN_ID}/data/settings`, {
data: {
actorUserId: OWNER_USER_ID,
schemaVersion: 1,
@@ -147,49 +132,28 @@ test.describe('Plugin support API', () => {
pluginVersion: manifest.version
}
}
}));
}), 410);
expect(stored.record).toEqual(expect.objectContaining({
key: 'settings',
pluginId: TEST_PLUGIN_ID,
schemaVersion: 1,
scope: 'server',
value: {
enabled: true,
pluginVersion: manifest.version
}
}));
expect(stored.errorCode).toBe('PLUGIN_DATA_DISABLED');
const listed = await expectJson<PluginDataListResponse>(await request.get(`${pluginsApi}/${TEST_PLUGIN_ID}/data`, {
const listed = await expectJson<{ errorCode: string }>(await request.get(`${pluginsApi}/${TEST_PLUGIN_ID}/data`, {
params: {
key: 'settings',
scope: 'server',
userId: OWNER_USER_ID
}
}));
}), 410);
expect(listed.records).toHaveLength(1);
expect(listed.records[0]?.value).toEqual({
enabled: true,
pluginVersion: manifest.version
});
expect(listed.errorCode).toBe('PLUGIN_DATA_DISABLED');
await expectJson<{ ok: boolean }>(await request.delete(`${pluginsApi}/${TEST_PLUGIN_ID}/data/settings`, {
const afterDelete = await expectJson<{ errorCode: string }>(await request.delete(`${pluginsApi}/${TEST_PLUGIN_ID}/data/settings`, {
data: {
actorUserId: OWNER_USER_ID,
scope: 'server'
}
}));
}), 410);
const afterDelete = await expectJson<PluginDataListResponse>(await request.get(`${pluginsApi}/${TEST_PLUGIN_ID}/data`, {
params: {
key: 'settings',
scope: 'server',
userId: OWNER_USER_ID
}
}));
expect(afterDelete.records).toEqual([]);
expect(afterDelete.errorCode).toBe('PLUGIN_DATA_DISABLED');
});
await test.step('WebSocket plugin API sends snapshots, relays server events, and rejects p2p relays', async () => {