feat(connections): opaque plugin-specific extra fields for ConnectionParams - #596
Conversation
…Params Adds a generic mechanism for plugins to carry custom connection settings (e.g. an AWS region for DynamoDB) without core schema changes. - ConnectionParams gains `extra: HashMap<String, String>` (Rust) and `extra?: Record<string, string>` (TS). Opaque to the host: persisted verbatim, forwarded to driver plugins, absent from JSON when empty. - New plugin slot `connection-modal.extra_fields` rendered below the host/port section; context exposes `driver`, `extra`, and `setExtraField(key, value)` so plugin UI can edit the map. - Pure `updateExtraField` helper in src/utils/connections.ts with unit tests (8 cases: set, merge, immutability, clear-on-empty, blank-key handling). - Host API version 0.1.0 -> 0.2.0 (HOST_API_VERSION, plugin-api API_VERSION + package.json) since the slot map is observable to plugin bundles. - PLUGIN_GUIDE slot table documents the new slot. Follow-up to TabularisDB/tabularis-dynamodb-plugin#59.
debba
left a comment
There was a problem hiding this comment.
Reviewed and tested this locally on Linux.
Full run on the branch: vitest 3490 passed across 194 files, cargo test --lib 1089 passed / 0 failed / 4 ignored, tsc --noEmit clean, eslint clean on the touched files, and clippy quiet in models.rs and plugins/driver.rs. So the Rust suite you couldn't run on that Windows box is green here, nothing to worry about on that front.
I checked the plumbing instead of just reading the diff. params_for_persistence clones the map so it survives save and update, duplicate_connection keeps it, every plugin RPC ships the whole params struct so drivers get extra on each call, and the edit path spreads the stored params back into the form, so opening and re-saving a connection doesn't quietly drop plugin fields. Legacy connections.json files still load fine and stay byte identical while the map is empty.
To exercise the new slot for real I wrote a small stub UI extension against connection-modal.extra_fields and drove it on a live MySQL connection: prefill from extra, per key edits, clear on empty, and the key disappearing from the persisted JSON once the last entry is gone all behave exactly as documented.
Clean, self contained design. Keeping driver specifics out of the core schema is the right call. Thanks!
Follow-up to the remaining core-side work from #593 (comment) — generic support for plugin-owned connection fields, not just DynamoDB.
What
extra: HashMap<String, String>on coreConnectionParams(Rust) +extra?: Record<string, string>(TS). Opaque to the host: persisted verbatim throughsave_connection/update_connection, forwarded to driver plugins as part ofparams, omitted from persisted JSON when empty (serde(default, skip_serializing_if)— legacy JSON deserializes to an empty map).connection-modal.extra_fields, rendered below the host/port section of the connection form. Context exposesdriver, the currentextramap, andsetExtraField(key, value)so a plugin UI can edit its own fields (empty value clears the key).updateExtraFieldpure helper insrc/utils/connections.tswith 8 unit tests (set / merge / immutability / clear-on-empty / blank-key / trim).HOST_API_VERSION, plugin-apiAPI_VERSION+package.json) — the slot map is observable to plugin bundles.PLUGIN_GUIDE.mdslot table updated.Verification
vitest: PASS (3490) FAIL (0) (incl. new helper tests)tsc --noEmit: cleaneslinton all touched files: 0 errorscargo clippy --all-targets: clean, no new warnings in touched filescheck:sync: OKrustfmton touched files: no new diffs vs upstream styleNote on local Rust test execution: on this Windows box the compiled test binary fails at load with
STATUS_ENTRYPOINT_NOT_FOUNDfrom an old systemcomctl32.dllmissingTaskDialogIndirect— reproduced identically on pristine upstream code, so it's a local-environment issue unrelated to this change; CI (Linux) runs the full Rust suite.Companion PR
DynamoDB plugin side (consumes
extra["region"]): TabularisDB/tabularis-dynamodb-plugin#59