fix(docsync): a paused binding no longer resets its own settings

PATCH links validated its body with a schema derived from the create
contract through .partial(). In Zod 4 a .default() still fires inside an
optional field, so a patch naming one setting arrived with every other
one filled in: pausing a pull-only binding switched it to two-way, reset
both policies and blanked its label. The update contract is now written
out without defaults, and an e2e test drives a patch through the real
pipe, which the controller unit tests never see.

Also, the cosmetic leftovers from the review:
- POST connections/:connectionId/scopes no longer wants the connection
  in the body as well. It was required, never read, and let one request
  name two connections; a client that still sends it has the key
  stripped rather than refused.
- createLink loses the scope argument every caller passed as null.
- The controller's owner check is now assertCanManage, because it lets
  instance admins through just as canManageDocSync does on the client.
  Who may manage a binding is unchanged.
- document_provider_fields drops settings_key and payload_key. Nothing
  read them: the connect form takes its fields from /docsync/providers
  and the admin shelf sends none for document providers.
- The e2e test imports the provider classes under their new names.
This commit is contained in:
Maurice
2026-09-19 12:06:06 +02:00
parent 01a7224f29
commit b88b92add7
11 changed files with 243 additions and 71 deletions
+3 -18
View File
@@ -126,26 +126,11 @@ export function seedDocumentProviders(db: Database.Database): void {
const insertField = db.prepare(
`INSERT OR IGNORE INTO document_provider_fields
(provider_id, field_key, label, input_type, placeholder, hint, required, secret, settings_key, payload_key, sort_order)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
(provider_id, field_key, label, input_type, placeholder, hint, required, secret, sort_order)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
);
for (const f of FIELDS) {
// settings_key and payload_key both carry the field key: every value lands
// in one JSON column here, but the generic client form reads those two and
// would need a branch if they were null.
insertField.run(
f.provider_id,
f.field_key,
f.label,
f.input_type,
f.placeholder,
f.hint,
f.required,
f.secret,
f.secret === 1 ? null : f.field_key,
f.field_key,
f.sort_order,
);
insertField.run(f.provider_id, f.field_key, f.label, f.input_type, f.placeholder, f.hint, f.required, f.secret, f.sort_order);
}
}
+6 -6
View File
@@ -4959,10 +4959,12 @@ function runMigrations(db: Database.Database): void {
* Journey cascade runs `UPDATE photo_providers SET enabled = 0` with no
* WHERE clause, and migrations are append-only — reusing those tables would
* change the behaviour of three existing paths, which is exactly what the
* no-breaking-changes rule forbids. The column set is copied verbatim so
* the same generic settings form renders both kinds without a special case,
* including `settings_key`/`payload_key`, which are redundant here (every
* value lands in one JSON column) but keep the client branch-free.
* no-breaking-changes rule forbids. The field columns follow
* `photo_provider_fields` except for `settings_key` and `payload_key`.
* Those map a photo field onto a settings key and a request key; a document
* field is stored under its own `field_key` in one JSON column, and the
* connect form takes its fields from /docsync/providers rather than from
* the generic settings form, so nothing would ever read them.
*/
() => {
db.exec(`
@@ -4985,8 +4987,6 @@ function runMigrations(db: Database.Database): void {
hint TEXT,
required INTEGER DEFAULT 0,
secret INTEGER DEFAULT 0,
settings_key TEXT,
payload_key TEXT,
sort_order INTEGER DEFAULT 0,
UNIQUE(provider_id, field_key)
);