mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 00:20:07 +00:00
feat(plugins): store plugin data on the engine TREK runs on
PLUGIN_DATA binds the plugin data backend to the engine (the same
{ sqlite, postgres }[engine.id] binding the backup port uses): the SQLite
file per plugin, unchanged, or the Postgres schema per plugin. The host
opens a plugin's store through it and an uninstall that deletes data erases
through it, which drops the schema on Postgres. Nothing outside db/engine
asks which engine runs.
A plugin's SQL is passed through as written, so a plugin needs to know the
dialect: db.engine (db:own) answers 'sqlite' or 'postgres', and the SDK
exposes it as ctx.db.engine(), in the mock host (dbEngine option) and in
dev. The plugin facts are regenerated and the SDK goes to 1.10.0.
The Postgres lane's PGPLUG suite installs, uses and erases plugin data on
Postgres and shows that a plugin reaches neither TREK's users table nor
another plugin's schema.
This commit is contained in:
@@ -511,6 +511,12 @@ describe('createMockHost', () => {
|
||||
await expect(ctx.db.tx(Array.from({ length: 101 }, () => ({ sql: 'SELECT 1' })))).rejects.toThrow(/at most 100/);
|
||||
});
|
||||
|
||||
it('db.engine says SQLite unless the mock is told the host runs Postgres, and needs db:own', async () => {
|
||||
await expect(createMockHost({ grants: ['db:own'] }).ctx.db.engine()).resolves.toBe('sqlite');
|
||||
await expect(createMockHost({ grants: ['db:own'], dbEngine: 'postgres' }).ctx.db.engine()).resolves.toBe('postgres');
|
||||
await expect(createMockHost({ grants: [] }).ctx.db.engine()).rejects.toThrow(/PERMISSION_DENIED/);
|
||||
});
|
||||
|
||||
it('member writes need member_manage + protect the owner; users.getById serves only public fields', async () => {
|
||||
const host = createMockHost({
|
||||
grants: ['db:write:members', 'db:read:users'],
|
||||
|
||||
Reference in New Issue
Block a user