fix(807): cover the two LIVE uncovered full-replace PUTs, correct four prose claims
Cold adversarial review returned BLOCKED. All findings confirmed by execution here before acting on them. H1 (blocker) — the change shipped with a live instance of the defect it claimed was latent. `MultiCollectionItemRequest.weight` and `UpdateFFmpegProfileRequest.qsvPreferNativeDecoder` are absent from their schemas' `required` arrays, so both emit optional, and both are the body of a full-replace PUT with a hand-built SPA body that the first commit did not cover. Deleting `weight: clampWeight(item.weight)` from `MultiCollectionsScreen.toItemRequest` typechecked CLEAN before this commit; the screen carries a prose comment warning that this exact drop resets every weight to 1 on save. It now reddens with TS2741. The bad reasoning is worth naming because it is a shape this repo keeps recording: "create/update" vs "replace" was sorted on the verb in the wrapper name rather than on what the endpoint does, and a property verified across the eleven schemas the six named builders touch was then reported as a property of the SPA. Coverage extended to `updateMultiCollection`, `updateFFmpegProfile`, `replaceDeco`, and both `mediaSources` replace wrappers. The FFmpeg fix surfaced a second instance one level down: the screen's `Draft` type and the `sampleRequest` test fixture both omitted `qsvPreferNativeDecoder`, so 30 green tests were exercising only the default. Both now `Complete<…>`. H3 — "two sites had lost the phantom direction" is five, and the stated cause was wrong. Measured: a fresh literal returned from a generic `.map` callback accepts a phantom field even with no spread and no inferred local, because `map<U>` infers `U` from the callback rather than from the target element type. Three of the five contain neither a spread nor a local, so the documented rule would have taught a reader that those are safe. M4 — the generator was named as the cause of nullable-emits-as-required. It is a pass-through (`required.has(name) ? '' : '?'`); the determinant is the `required` array in the ASP.NET-produced `ErsatzTV/wwwroot/openapi/v1.json`. Pointed three durable places at the right file. M5 — the guard's header claimed every case reddens under every weakening, which its own case-4 comment contradicted. Replaced with the measured table. L6/L7/L8/N10 — record frontmatter now carries #807 so catalog-first lookup finds it (catalog regenerated); `guard-inventory.md`'s hand-written out-of-population list gains the third TS guard and now says why such a mirror goes stale silently; `Complete` exported from the api barrel; §4b moved after §4a. H2 is not fixed and is not implied closed: this guard proves `Complete<T>`'s semantics, not that it is APPLIED — reverting one screen leaves it green. Filed as #820 and named as residue on the record. Verification: typecheck 0, eslint 0, 1200/1200 web tests, 833 passed 2 skipped in scripts/tests, catalog regenerates to a zero diff, doc-narrative 0 warnings. refs #820 Decisions-Edit: yes
This commit is contained in:
@@ -201,7 +201,7 @@ the link for rationale. Superseded/retired history lives in `archive/`. Regenera
|
||||
| `testing.e2e-local-fresh-config-dir` | Always point `scripts/e2e-local.sh` at a fresh config dir — leftover channels/schedules/DB rows bleed state between runs and corrupt assertions. (The *readiness-probe hang* this record was originally written about was fixed in #533; the fresh-dir rule stands on state-bleed grounds alone.) | 2026-07-21 | [link](records/testing/e2e-local-fresh-config-dir.md) |
|
||||
| `testing.enumerating-guard-identity-not-position` | A guard that cross-checks a hand-reviewed registry against call sites discovered across the whole repo must key each entry on properties INTRINSIC to the site — file, kind, and the value source text — and never on its absolute line or column. A registry keyed on position is a function of every other file in the repo, so a branch that never touches the guard can invalidate it; and because each PR is green against its own base, that failure is structurally invisible pre-merge and lands on `main` after review and after the merge gate. Dropping the position keeps every mutation the guard exists for — a NEW site, a REMOVED site and a CHANGED value each still fail, since each changes the identity multiset — and costs exactly ONE case, which must be stated rather than implied: a SAME-IDENTITY SUBSTITUTION within one file (delete a registered site, add a different unreviewed one with the same kind and value token, net-zero count) now passes. A REPORTED failure still prints the discovered line:column, because identity and diagnostics need not share a format. Comparison stays a MULTISET count rather than set membership, so two sites in one file sharing an identity must be discovered exactly that many times and a third occurrence still fails. A SCANNER test that asserts real AST positions against FIXED inline fixtures is the opposite case and keeps its line/column identity — it has no churn, because its input does not move. | 2026-07-27 | [link](records/testing/enumerating-guard-identity-not-position.md) |
|
||||
| `testing.fix-ships-a-witnessed-red-test` | A commit claiming to fix something may carry a `Proves: <pytest selector>` trailer; when it does, `scripts/prove-fix.sh` must show that selector GREEN with the fix and RED with the code side reverted, and CI enforces it per-PR. The trailer is opt-in — an unproven commit is allowed — but a claimed proof that does not hold fails the build. | 2026-08-16 | [link](records/testing/fix-ships-a-witnessed-red-test.md) |
|
||||
| `testing.full-replace-asserts-field-list` | Any path that writes a WHOLE entity or a WHOLE child collection — a PUT-replace handler, a hand-built request object, a test comparer standing in for one — derives its field list from the authoritative type and asserts SET EQUALITY against it, rather than enumerating the fields by hand. A hand-written list is correct on the day it is written and structurally unable to report the day it stops being: the field that drifts is the one nobody wrote a line for, so no amount of care in the existing lines can reach it. The failure is silent by construction — a full replace with a field omitted returns HTTP 200 and destroys that field's value (#754 drifted from a 28-property DTO by one and cleared it; the symptom arrived hours later as missing pixels). SECOND CLAUSE, separable from the first: where a replaced child row carries state keyed to its identity — progression, ordering, an enumerator position — the handler RECONCILES BY ID rather than delete-and-reinsert, because reinsertion silently resets state a client never asked to touch (#252: a schedule PUT reset fill-group progression; #500: a dedup fix became permanent data loss because the add filter and the remove filter used different keys, so the two halves must agree on the key). Delete-and-reinsert is acceptable ONLY where no such state exists, and that emptiness is a fact about today's schema that a later feature can silently invalidate — so record it where the handler is, dated, rather than leaving it to be re-derived. The canonical worked example is `ToolCatalogTests.Every_Write_Tool_Should_Declare_Exactly_Its_OpenApi_Request_Body_Fields`, which reads the accepted fields from the generated OpenAPI document and compares both directions. | 2026-08-21 | [link](records/testing/full-replace-asserts-field-list.md) |
|
||||
| `testing.full-replace-asserts-field-list` | Any path that writes a WHOLE entity or a WHOLE child collection — a PUT-replace handler, a hand-built request object, a test comparer standing in for one — derives its field list from the authoritative type and asserts SET EQUALITY against it, rather than enumerating the fields by hand. A hand-written list is correct on the day it is written and structurally unable to report the day it stops being: the field that drifts is the one nobody wrote a line for, so no amount of care in the existing lines can reach it. The failure is silent by construction — a full replace with a field omitted returns HTTP 200 and destroys that field's value (#754 drifted from a 28-property DTO by one and cleared it; the symptom arrived hours later as missing pixels). SECOND CLAUSE, separable from the first: where a replaced child row carries state keyed to its identity — progression, ordering, an enumerator position — the handler RECONCILES BY ID rather than delete-and-reinsert, because reinsertion silently resets state a client never asked to touch (#252: a schedule PUT reset fill-group progression; #500: a dedup fix became permanent data loss because the add filter and the remove filter used different keys, so the two halves must agree on the key). Delete-and-reinsert is acceptable ONLY where no such state exists, and that emptiness is a fact about today's schema that a later feature can silently invalidate — so record it where the handler is, dated, rather than leaving it to be re-derived. The canonical worked example is `ToolCatalogTests.Every_Write_Tool_Should_Declare_Exactly_Its_OpenApi_Request_Body_Fields`, which reads the accepted fields from the generated OpenAPI document and compares both directions. ON THE SPA SIDE the same rule is enforced by the TYPE SYSTEM rather than by a test: a full-replace body is built as `Complete<T>` (`web/src/api/completeRequest.ts`), a mapped type that makes every member of a generated request type required, so a builder that omits one fails `npm run typecheck`. Annotate BOTH the API-wrapper parameter (so later callers inherit it) AND each construction site including every `.map` callback return type, because the excess-property check that catches a PHANTOM field fires only on a fresh literal in a contextually typed position and a generic `.map` callback is not one. Do not infer from "most builders already typecheck" that the gap is closed: a member is omittable exactly when it is absent from the schema `required` array in the ASP.NET-produced OpenAPI document, and two live cases (#807) sat unchecked inside a large majority of checked ones. | 2026-08-21 | [link](records/testing/full-replace-asserts-field-list.md) |
|
||||
| `testing.guard-derives-population-from-source` | A guard that asserts a COMPLETENESS property enumerates its population from a machine-readable authoritative source — the enum, the generated OpenAPI document, the parsed workflow YAML, the provider list — and asserts SET EQUALITY in BOTH directions against it. It may not narrow that population with a filter, a `Where`, a `grep` or an early `continue` before the assertion, because a filter cannot see the member that is MISSING: the member whose absence is the defect is precisely the one the predicate excludes. A hand-written literal list of members is the same defect in slower motion — a filter frozen at authoring time, correct on the day it was written and unable to report the day it stopped being. Two boundaries bound the rule rather than weaken it. FIRST, filtering to select the SUBJECT of a PER-MEMBER property is legitimate and is not this defect: the excluded members satisfy the property vacuously, so the filtered walk and the whole walk assert the same thing (`ToolCatalogTests.Every_Query_Parameter_Should_Be_A_Declared_Property` filters to tools that declare query parameters, and a tool declaring none has nothing to check). The defect is filtering the population before a COMPLETENESS claim, which is what makes an absent member unrepresentable (#757 filtered on `QueryParameters is {Count: > 0}` and so could not see a tool that should have declared one and did not). SECOND, a population of VALUES always has an external authoritative source and this rule applies directly; a population of SITES IN CODE has no such list, needs find-all-references tooling, and is tracked separately in #777 — do not stretch a set-equality assertion over it. Distinguish the guard SCOPE (which subsystems it covers — a reviewed policy choice, legitimately hand-written) from the guard POPULATION (the members inside that scope — always derived). When the scope itself MIRRORS an authoritative source, the mirror needs its own equality check or a dated staleness marker, or the guard is complete within a scope that has silently gone stale. The canonical worked example in this repo is `ToolCatalogTests.Every_Tool_Should_Declare_Exactly_Its_OpenApi_Query_Parameters`; the canonical residual gap is `MARKED_JOBS` in `scripts/tests/test_ci_dropped_step_guard.py`. WHEN THE POPULATION IS FILES (#806), the authoritative source is the GIT INDEX and never a filesystem walk. A walk is not merely a weaker enumerator, it answers a question about the MACHINE rather than about the repo: it reports build output, generated shims and editor droppings, and it differs between CI and every checkout, so the same guard asserts a different population in each place. Derive with `git ls-files`, take direct children only unless a nested population is stated and wanted, and assert existence rather than filtering on it, because filtering is what makes a missing member unrepresentable. This is an instantiation and not a blanket rewrite: the question per guard remains whether it makes a COMPLETENESS claim over TRACKED files, and a walk that assembles a fixture or selects the SUBJECT of a per-member property stays a walk with its reason written down. | 2026-08-13 | [link](records/testing/guard-derives-population-from-source.md) |
|
||||
| `testing.guard-ships-with-mutation-proof` | A guard is not considered tested because a test involving it passes. It ships with a MUTATION PROOF: remove or disarm THAT GUARD'S CLAUSE ALONE, and a NAMED test must go red. ONE NAMED EXCEPTION, with its limits, because the rule degenerates without it: where the guard IS a test (a checker enforcing a repo invariant, with no separate script behind it), disarming it makes it ABSENT rather than red, so the proof is the contrapositive — INTRODUCE THE DEFECT THE GUARD EXISTS TO CATCH into an isolated copy of the guarded artifact, and the named test must go red. That is a mutation of the guarded SYSTEM rather than of the assertion, and it is admissible ONLY for checker-guards and ONLY when the mutation was executed and witnessed. It is NOT a licence to grade an ordinary script-guard MUTATION for having a bad-input test: feeding a script an input its clause rejects is BEHAVIOUR-ONLY, which is what three rows were regraded for. A file-level grade under this exception covers the clause its cited case actually mutates, not every assertion that later lands in the same file. Three things this excludes, each of which has already shipped here as a green suite over a dead check. FIRST, a behavioural test — one that feeds the guard a good input and a bad input and checks it passes and fails — proves the guard REACTS, never that it is LOAD-BEARING; #685 had two guards on one condition where deleting either left the whole suite green while every behavioural test passed. SECOND, mutating the WHOLE FILE does not count (#510): a whole-file revert cannot show that a test reaches a particular clause, so the mutation must target the clause. THIRD, the guard being WIRED is not the guard RUNNING — #631's suite was invoked by no CI job, #751's step was dropped by the runner and the job reported success in 6s against a normal 14-17s, and #719's new logic was never connected to stdin. Every guard that DERIVES A POPULATION also carries an ANTI-VACUITY assertion, because the characteristic failure of a completeness check is reporting that it proved everything while its population was empty; a guard with no population has nothing for such an assertion to be about, and stating it universally reads as coverage the unproven rows do not have. Mechanical enforcement is possible for the BOOKKEEPING and not for the JUDGEMENT, and the split is the decision: `docs/guard-inventory.md` lists every guard file with its Kind, its Proof class (`MUTATION`/`BEHAVIOUR-ONLY`/`NONE`) and a `file::function` ref, and `scripts/tests/test_guard_inventory.py` derives the guard population from the GIT INDEX and the call sites (#806), asserts SET EQUALITY against the rows, and resolves every claimed ref to a real `def`. So a new guard cannot ship unclassified and a renamed test cannot leave a row silently claiming coverage. Whether a row claiming `MUTATION` is telling the truth is no longer left to review: `testing.mutation-claims-are-executed` (#790) requires each such row to carry a DECLARED clause mutation that is applied to an isolated copy of the repository on every run, with the row's own named test required to go red. | 2026-08-13 | [link](records/testing/guard-ships-with-mutation-proof.md) |
|
||||
| `testing.hook-reports-its-own-execution` | Every script in `.claude/hooks/` sources `scripts/hook-fire-log.sh` and calls `etv_hook_fire_begin <its-own-name> <label> <capture\|stream>` as its FIRST act, before anything reads stdin. Two records are appended per invocation — a `fire` record on entry and an `exit` record carrying the exit status and the decision — to a session-scoped JSONL log. THE DECISION IS READ FROM WHAT THE HOOK ACTUALLY EMITTED, never declared by the hook author: Claude Code hooks (`capture` mode) always exit 0 and communicate by PRINTING JSON, so their stdout is diverted and replayed, and the recorded decision is parsed from those bytes; git hooks (`stream` mode) decide by EXIT CODE and their stdout is live progress text a human is watching, so it is not diverted and the decision is the status. That split is not a tuning knob — capturing a slow pre-push hook's output would hold it back until the end and read as a hang, and inferring a git hook's decision from absent JSON would put the report back into the guessing business this record exists to end. The population is DERIVED from `.claude/hooks/*.sh` by `scripts/tests/test_hook_fire_log.py`, so a new hook is uninstrumented-and-red rather than silently unobserved, and the report lists every hook that EXISTS rather than every hook that appears in the log — a report built from the log alone can only show hooks that fired, which makes the never-fired hook, the one finding worth having, invisible. THE INSTRUMENTATION MUST BE INVISIBLE TO THE HARNESS, and this is the load-bearing half: it sits in the stdin and stdout path of the most authoritative guards in the repo, so a differential test drives EVERY hook with and without it over a payload matrix and demands byte-equal stdout and equal exit status. It fails OPEN in exactly one direction — if the log cannot be written the hook behaves exactly as before — because observability that breaks a guard is worse than the blindness it replaces. Two mechanical traps are pinned by tests rather than left to care: stdout must be replayed from the FILE, since `out=$(cat f)` strips trailing newlines and delivers a guard's JSON one byte short with no parser anywhere to complain; and stdin must never be slurped when it is a TTY, because an interactive `git commit` hands its hooks a terminal and `cat` would block forever, hanging the commit the instrumentation was added to observe. | 2026-08-14 | [link](records/testing/hook-reports-its-own-execution.md) |
|
||||
|
||||
@@ -5,8 +5,8 @@ status: active
|
||||
since: '2026-08-21'
|
||||
supersedes: none
|
||||
superseded-by: none
|
||||
rule: 'Any path that writes a WHOLE entity or a WHOLE child collection — a PUT-replace handler, a hand-built request object, a test comparer standing in for one — derives its field list from the authoritative type and asserts SET EQUALITY against it, rather than enumerating the fields by hand. A hand-written list is correct on the day it is written and structurally unable to report the day it stops being: the field that drifts is the one nobody wrote a line for, so no amount of care in the existing lines can reach it. The failure is silent by construction — a full replace with a field omitted returns HTTP 200 and destroys that field''s value (#754 drifted from a 28-property DTO by one and cleared it; the symptom arrived hours later as missing pixels). SECOND CLAUSE, separable from the first: where a replaced child row carries state keyed to its identity — progression, ordering, an enumerator position — the handler RECONCILES BY ID rather than delete-and-reinsert, because reinsertion silently resets state a client never asked to touch (#252: a schedule PUT reset fill-group progression; #500: a dedup fix became permanent data loss because the add filter and the remove filter used different keys, so the two halves must agree on the key). Delete-and-reinsert is acceptable ONLY where no such state exists, and that emptiness is a fact about today''s schema that a later feature can silently invalidate — so record it where the handler is, dated, rather than leaving it to be re-derived. The canonical worked example is `ToolCatalogTests.Every_Write_Tool_Should_Declare_Exactly_Its_OpenApi_Request_Body_Fields`, which reads the accepted fields from the generated OpenAPI document and compares both directions.'
|
||||
signals: 'full replace asserts its field list · hand-maintained mirror drifts by one field · reconcile by id not delete and reinsert · 200 and the field is gone · add filter and remove filter must share a key · fill-group progression reset by a PUT · derive the comparer from the DTO · a lossless round-trip test that is itself a hand-copied list · anti-vacuity PIN not a floor on a reflective walk · stale exemption must still name a real property · a complete comparer over a hand-written fixture · universal negative in a record is a trap · paths: `ErsatzTV.Tests/Application/ProgramSchedules/ScheduleItemResponseRoundTripTests.cs`, `ErsatzTV.Mcp.Tests/ToolCatalogTests.cs`, `ErsatzTV.Application/ProgramSchedules/Commands/ReplaceProgramScheduleItemsHandler.cs` · issues: #779, #773, #757, #754, #500, #252'
|
||||
rule: 'Any path that writes a WHOLE entity or a WHOLE child collection — a PUT-replace handler, a hand-built request object, a test comparer standing in for one — derives its field list from the authoritative type and asserts SET EQUALITY against it, rather than enumerating the fields by hand. A hand-written list is correct on the day it is written and structurally unable to report the day it stops being: the field that drifts is the one nobody wrote a line for, so no amount of care in the existing lines can reach it. The failure is silent by construction — a full replace with a field omitted returns HTTP 200 and destroys that field''s value (#754 drifted from a 28-property DTO by one and cleared it; the symptom arrived hours later as missing pixels). SECOND CLAUSE, separable from the first: where a replaced child row carries state keyed to its identity — progression, ordering, an enumerator position — the handler RECONCILES BY ID rather than delete-and-reinsert, because reinsertion silently resets state a client never asked to touch (#252: a schedule PUT reset fill-group progression; #500: a dedup fix became permanent data loss because the add filter and the remove filter used different keys, so the two halves must agree on the key). Delete-and-reinsert is acceptable ONLY where no such state exists, and that emptiness is a fact about today''s schema that a later feature can silently invalidate — so record it where the handler is, dated, rather than leaving it to be re-derived. The canonical worked example is `ToolCatalogTests.Every_Write_Tool_Should_Declare_Exactly_Its_OpenApi_Request_Body_Fields`, which reads the accepted fields from the generated OpenAPI document and compares both directions. ON THE SPA SIDE the same rule is enforced by the TYPE SYSTEM rather than by a test: a full-replace body is built as `Complete<T>` (`web/src/api/completeRequest.ts`), a mapped type that makes every member of a generated request type required, so a builder that omits one fails `npm run typecheck`. Annotate BOTH the API-wrapper parameter (so later callers inherit it) AND each construction site including every `.map` callback return type, because the excess-property check that catches a PHANTOM field fires only on a fresh literal in a contextually typed position and a generic `.map` callback is not one. Do not infer from "most builders already typecheck" that the gap is closed: a member is omittable exactly when it is absent from the schema `required` array in the ASP.NET-produced OpenAPI document, and two live cases (#807) sat unchecked inside a large majority of checked ones.'
|
||||
signals: 'full replace asserts its field list · hand-maintained mirror drifts by one field · reconcile by id not delete and reinsert · 200 and the field is gone · add filter and remove filter must share a key · fill-group progression reset by a PUT · derive the comparer from the DTO · a lossless round-trip test that is itself a hand-copied list · anti-vacuity PIN not a floor on a reflective walk · stale exemption must still name a real property · a complete comparer over a hand-written fixture · universal negative in a record is a trap · the SPA builds a full-replace body as `Complete<T>` · a member is omittable only when it is absent from the OpenAPI `required` array · excess-property checking does not fire inside a generic `.map` callback · a comment warning about a silent reset is not a check · `weight` · `qsvPreferNativeDecoder` · paths: `ErsatzTV.Tests/Application/ProgramSchedules/ScheduleItemResponseRoundTripTests.cs`, `ErsatzTV.Mcp.Tests/ToolCatalogTests.cs`, `ErsatzTV.Application/ProgramSchedules/Commands/ReplaceProgramScheduleItemsHandler.cs`, `web/src/api/completeRequest.ts`, `web/src/api/completeRequest.guard.test.ts` · issues: #807, #779, #773, #757, #754, #500, #252'
|
||||
mechanics: 'Detector G of `docs/defect-shapes-773.md` §4. Enforced per-site by a reflective comparison over the DTO plus a written-down count pin, not by a repo-wide check — see the record body for why a global one is not proposed. The exemption set is empty today; the machinery guarding exemptions remains for the first one that earns its place.'
|
||||
---
|
||||
|
||||
@@ -130,34 +130,51 @@ be a name matcher over handler classes ending `Replace…Handler`, which misses
|
||||
and flags the ones that do it correctly. Per-site derivation, applied when a full-replace path is
|
||||
touched, is the enforceable version.
|
||||
|
||||
**The SPA half, closed by #807 — and the premise this record stated for it was wrong.** The residue
|
||||
recorded here was that the SPA builds request objects field-by-field in six screens
|
||||
(`normalizeForSave` and its equivalents), so an *optional* field added to the DTO and not carried
|
||||
through would compile clean and drop silently. On audit (2026-08-22) that mechanism was **latent,
|
||||
not live**: `scripts/generate-openapi-types.mjs` renders a nullable DTO property as a REQUIRED
|
||||
member of a nullable type (`"name": null | string`), not as an optional one, and not one of the
|
||||
eleven request schemas those six builders target declares a single `?:` member. `tsc` was therefore
|
||||
already checking all of them. The protection was real but *contingent* — on a generator behaviour
|
||||
nothing asserts, for a set of DTOs none of which had yet acquired an optional property. Optional
|
||||
members do occur elsewhere in the same generated file (the Auto-Tune lineup-request family), so the
|
||||
contingency was one modelling decision away from lapsing, silently and with no other net watching.
|
||||
**The SPA half, and the premise this record originally stated for it was wrong TWICE — first by
|
||||
understating the risk, then by overstating the fix.** The residue recorded here was that the SPA
|
||||
builds request objects field-by-field in six screens (`normalizeForSave` and its equivalents), so
|
||||
an *optional* field added to a DTO and not carried through would compile clean and drop silently.
|
||||
|
||||
`Complete<T>` (`web/src/api/completeRequest.ts`) removes the contingency instead of asserting the
|
||||
generator's current behaviour: it maps a request type so every member is required, so a builder that
|
||||
omits one fails `npm run typecheck` however the generator emitted it. It is applied at the
|
||||
The first correction was that the mechanism looked latent: the generated types mark a member
|
||||
omittable (`?:`) only when it is absent from the schema's `required` array in
|
||||
`ErsatzTV/wwwroot/openapi/v1.json`, and nullable properties usually emit as required-and-nullable
|
||||
(`"name": null | string`), so none of the eleven request schemas those six builders target has an
|
||||
optional member and `tsc` was already checking all of them.
|
||||
|
||||
**That framing was itself the defect this repo keeps recording — a boundary drawn around the cases
|
||||
examined and then reported as a property of the whole.** It is true of those eleven schemas and
|
||||
false of the SPA. Two full-replace PUTs outside that set carry a live optional member (verified by
|
||||
execution 2026-08-22, by deleting the field and watching `npm run typecheck` stay CLEAN):
|
||||
|
||||
| schema | optional member | wrapper | consequence of the drop |
|
||||
|---|---|---|---|
|
||||
| `MultiCollectionItemRequest` | `weight` | `updateMultiCollection` (PUT) | every weight resets to 1 on save |
|
||||
| `UpdateFFmpegProfileRequest` | `qsvPreferNativeDecoder` | `updateFFmpegProfile` (PUT) | the setting reverts to its default |
|
||||
|
||||
`MultiCollectionsScreen` carries a prose comment warning about precisely that reset. A comment is
|
||||
not a check, and the sort that put these two in an exempt "create/update" bucket was reading the
|
||||
verb in the function name rather than what the endpoint does.
|
||||
|
||||
**`Complete<T>`** (`web/src/api/completeRequest.ts`) maps a request type so every member is
|
||||
required, making an omission a hard error however the schema was modelled. It is applied at the
|
||||
full-replace API-wrapper boundary — so future callers inherit it without knowing it exists — and at
|
||||
each of the six construction sites, which is what keeps TypeScript's excess-property check (the
|
||||
*phantom* direction) alive; two of those sites had lost it by building through an inferred local or
|
||||
a spread rather than a fresh annotated literal.
|
||||
each construction site, which is what keeps TypeScript's excess-property check (the *phantom*
|
||||
direction) alive. That direction fires only on a fresh literal in a contextually typed position,
|
||||
and a literal returned from a generic `.map` callback is not one, because `map<U>` infers `U` from
|
||||
the callback rather than from the target element type: five of the nine construction sites accepted
|
||||
a phantom field beforehand, and three of those contained neither a spread nor an inferred local.
|
||||
|
||||
Measured rather than argued (2026-08-22): injecting an optional member into `ScheduleItemRequest`
|
||||
reddens `normalizeForSave` with `TS2741` under `Complete<T>`, and compiles **clean** without it —
|
||||
the negative control is the defect itself. The proof ships as `@ts-expect-error` cases in
|
||||
`web/src/api/completeRequest.guard.test.ts`, re-executed on every `npm run typecheck` (a marked CI
|
||||
step) rather than witnessed once by hand.
|
||||
Measured, not argued (2026-08-22): injecting an optional member into `ScheduleItemRequest` reddens
|
||||
`normalizeForSave` with `TS2741` under `Complete<T>` and compiles clean without it; deleting
|
||||
`weight` from `MultiCollectionsScreen.toItemRequest` now reddens and previously did not. The proof
|
||||
ships as `@ts-expect-error` cases in `web/src/api/completeRequest.guard.test.ts`, re-executed on
|
||||
every `npm run typecheck` (a marked CI step).
|
||||
|
||||
**Residue that remains**, stated rather than implied closed. `Complete<T>` is shallow, so a NEW
|
||||
nested item request type needs its own annotation and nothing forces that. It is applied to the
|
||||
full-replace bodies only, not to the create/update endpoints. And the fixture caveat above still
|
||||
applies here: requiring a field to be *named* is not the same as requiring it to be *populated*
|
||||
correctly.
|
||||
**Residue, named rather than implied closed.** `Complete<T>` proves its own semantics but NOT that
|
||||
it is applied: reverting one screen to its pre-#807 form leaves the guard green, because the
|
||||
population of construction sites is derived from nothing. The repo already owns the tool for that
|
||||
— `web/src/api/pageSizeScan.ts` (TypeScript compiler API) plus a registry cross-checked in both
|
||||
directions — and building it is tracked in #820. Until then this convention is enforced by review,
|
||||
which is the weaker thing this record exists to warn about. Separately: `Complete<T>` is shallow,
|
||||
so a new nested item request type needs its own annotation; and requiring a field to be *named* is
|
||||
not the same as requiring it to be *populated* correctly.
|
||||
|
||||
@@ -56,8 +56,11 @@ inventory shipped with were sitting in the gap:
|
||||
1. **Guards inline in workflow YAML** — most importantly `pr-checks.yml:ci-image-pin`. "Which jobs
|
||||
are guards" needs a judgement call per job the filesystem cannot supply. Two were audited under
|
||||
#774 and one fixed; extending the population is tracked in #786.
|
||||
2. **C# and TypeScript guards** — `ErsatzTV.Mcp.Tests/ToolCatalogTests.cs` and
|
||||
`web/src/api/pageSizeCallSites.guard.test.ts` are both structural guards and neither has a row.
|
||||
2. **C# and TypeScript guards** — `ErsatzTV.Mcp.Tests/ToolCatalogTests.cs`,
|
||||
`web/src/api/pageSizeCallSites.guard.test.ts` and `web/src/api/completeRequest.guard.test.ts`
|
||||
are all structural guards and none has a row. Note what that costs: this list is a HAND-WRITTEN
|
||||
mirror of a population nothing derives, so it goes stale silently and CI stays green — #807
|
||||
added the third entry, and only review caught that the second had become the only one named.
|
||||
3. **Mentions counted as call sites.** The `scripts/…` scrape matches any occurrence, including
|
||||
inside a comment or an `::error::` string. `scripts/update-openapi.sh` is named in a
|
||||
`pr-checks.yml` error message, so removing the step that runs it would leave its row intact.
|
||||
|
||||
+38
-32
@@ -407,38 +407,6 @@ spec-cased vs runtime-cased key (the old `PlaybackTroubleshootingScreen` `#198`
|
||||
`data.channel.fFmpegProfileId` has been removed — read `ffmpegProfileId` straight off the typed
|
||||
response). When you mock an API response in a test, use the generated (runtime) casing.
|
||||
|
||||
## 4b. Full-replace request bodies are built as `Complete<T>` (#807)
|
||||
|
||||
A full-replace endpoint writes the WHOLE entity, so a field the builder never sets is not left
|
||||
alone — it is written as its default. Build every full-replace body against
|
||||
`Complete<T>` (`web/src/api/completeRequest.ts`), which maps a generated request type so **every**
|
||||
member is required:
|
||||
|
||||
```ts
|
||||
function toReplaceRequest(draft: Draft): Complete<ReplaceBlockRequest> { … }
|
||||
items.map((item): Complete<DecoTemplateItemRequest> => ({ … }))
|
||||
```
|
||||
|
||||
Two rules, and the second is the one that gets skipped:
|
||||
|
||||
- **Annotate the wrapper parameter** (`body: Complete<ReplaceBlockRequest>`) so every caller —
|
||||
including ones written later by someone who never read this — inherits the check.
|
||||
- **Annotate each construction site too**, including a `.map` callback's return type. The wrapper
|
||||
annotation catches a *missing* field anywhere, but TypeScript's excess-property check (a
|
||||
*phantom* field the schema does not accept) only fires on a **fresh object literal in a typed
|
||||
position**. Building through an inferred local (`const buildRequest = () => ({ … })`) or a spread
|
||||
(`...toRequestRecurrence(item)`) silently loses that direction — both had, before #807.
|
||||
|
||||
An optional member may be written `field: undefined`. The point is not to forbid omitting a value,
|
||||
it is to forbid omitting the *decision*: an unmentioned field is an oversight, an explicit
|
||||
`undefined` is a choice a reviewer can see.
|
||||
|
||||
Why this exists even though `tsc` appears to catch it already: it only does because the generator
|
||||
happens to emit nullable properties as required-and-nullable (`"name": null | string`) rather than
|
||||
optional. That is contingent, not guaranteed — see
|
||||
`docs/decisions/records/testing/full-replace-asserts-field-list.md`, and
|
||||
`web/src/api/completeRequest.guard.test.ts` for the executed proof.
|
||||
|
||||
## 4a. Optimistic-concurrency editors (ETag / If-Match / 412)
|
||||
|
||||
Replace-all editors (Blocks is the reference; see `api-conventions.md` §7a for the server contract,
|
||||
@@ -478,6 +446,44 @@ fresher edit:
|
||||
(authoritative) — never let an out-of-range value reach the server and surface a raw 400. Mirror the
|
||||
server's bound as a shared const (e.g. multi-collection weight `WEIGHT_MIN`/`WEIGHT_MAX` = 1..1000, #404).
|
||||
|
||||
## 4b. Full-replace request bodies are built as `Complete<T>` (#807)
|
||||
|
||||
A full-replace endpoint writes the WHOLE entity, so a field the builder never sets is not left
|
||||
alone — it is written as its default. Build every full-replace body against `Complete<T>`
|
||||
(`web/src/api/completeRequest.ts`), which maps a generated request type so **every** member is
|
||||
required:
|
||||
|
||||
```ts
|
||||
function toReplaceRequest(draft: Draft): Complete<ReplaceBlockRequest> { … }
|
||||
items.map((item): Complete<DecoTemplateItemRequest> => ({ … }))
|
||||
```
|
||||
|
||||
Two rules, and the second is the one that gets skipped:
|
||||
|
||||
- **Annotate the wrapper parameter** (`body: Complete<ReplaceBlockRequest>`) so every caller —
|
||||
including ones written later by someone who never read this — inherits the check.
|
||||
- **Annotate each construction site too, including every `.map` callback's return type.** The
|
||||
wrapper annotation catches a *missing* field anywhere. The *phantom* direction (a field the
|
||||
schema does not accept) relies on TypeScript's excess-property check, which fires only on a
|
||||
**fresh object literal in a contextually typed position** — and a literal returned from a generic
|
||||
`.map` callback is not one, because `map<U>` infers `U` from the callback's return rather than
|
||||
from the target element type. A spread or an inferred local loses it too, but the `.map` callback
|
||||
is the common case and the easy one to misread as safe: five of nine construction sites accepted
|
||||
a phantom field before #807, and three of those five contained neither a spread nor a local.
|
||||
|
||||
An optional member may be written `field: undefined`. The point is not to forbid omitting a value,
|
||||
it is to forbid omitting the *decision*: an unmentioned field is an oversight, an explicit
|
||||
`undefined` is a choice a reviewer can see.
|
||||
|
||||
Why this is needed even though most builders already typecheck: a member is omittable exactly when
|
||||
the generated type marks it `?:`, which comes from the `required` array of the schema in
|
||||
`ErsatzTV/wwwroot/openapi/v1.json` — the generator script only passes it through. Most nullable
|
||||
properties emit as required-and-nullable, so the gap looks closed on inspection while a small
|
||||
minority (`MultiCollectionItemRequest.weight`, `UpdateFFmpegProfileRequest.qsvPreferNativeDecoder`
|
||||
today) sits unchecked inside it. See
|
||||
`docs/decisions/records/testing/full-replace-asserts-field-list.md`, and
|
||||
`web/src/api/completeRequest.guard.test.ts` for the executed proof.
|
||||
|
||||
## 5. Artwork rendering
|
||||
|
||||
Render `item.artwork` / `item.poster` (or whatever the DTO field is named) **directly as an `<img
|
||||
|
||||
@@ -11,11 +11,26 @@ import type { components } from './generated/v1';
|
||||
* real one in the sense `testing.guard-ships-with-mutation-proof` requires: each directive
|
||||
* INTRODUCES THE DEFECT the guard exists to catch, and `tsc` fails the build if the defect is NOT
|
||||
* reported. A `@ts-expect-error` on a line that compiles cleanly is itself an error
|
||||
* (`TS2578: Unused '@ts-expect-error' directive`), so weakening `Complete<T>` — to
|
||||
* `Partial<T>`, to `T`, or by deleting the mapped type entirely — turns every case below red.
|
||||
* That mutation runs on every `npm run typecheck`, which is a marked CI step
|
||||
* (`docker-build.yml` → `ci-step-ran.sh mark typecheck`), rather than being executed once by hand
|
||||
* and asserted in prose.
|
||||
* (`TS2578: Unused '@ts-expect-error' directive`). That mutation runs on every
|
||||
* `npm run typecheck`, which is a marked CI step (`docker-build.yml` → `ci-step-ran.sh mark
|
||||
* typecheck`), rather than being executed once by hand and asserted in prose.
|
||||
*
|
||||
* Which mutation reddens which case, measured 2026-08-22 and NOT generalised beyond it:
|
||||
*
|
||||
* | mutation of `Complete<T>` | cases that go red |
|
||||
* |---|---|
|
||||
* | `{ [K in keyof T]: T[K] }` (drop `Required` — the realistic weakening) | 2 |
|
||||
* | `T` (delete the mapped type) | 2 |
|
||||
* | `Partial<T>` | 2 and 4 |
|
||||
*
|
||||
* Case 2 is the load-bearing one; cases 1, 3 and 5 stay green under all three, by design (1 and 3
|
||||
* are controls that MUST stay green, and 5's excess-property check does not depend on `Required`).
|
||||
* An earlier version of this comment claimed every case reddens under every weakening. It does
|
||||
* not, and the difference matters: a proof that overstates its own reach stops being re-examined.
|
||||
*
|
||||
* What this file does NOT prove is that `Complete<T>` is APPLIED at every site that needs it.
|
||||
* Reverting one screen to its pre-#807 form leaves this guard green — the population of
|
||||
* construction sites is not derived from anything. That residue is tracked, not implied closed.
|
||||
*
|
||||
* Both directions are covered, because a MISSING field and a PHANTOM field are opposite defects:
|
||||
* cases 2 and 4 are the missing direction (the #807 defect proper — a silently dropped field on a
|
||||
|
||||
@@ -8,27 +8,28 @@
|
||||
* schema types in `./generated/v1.d.ts`. Those bodies are sent to full-replace endpoints, so a
|
||||
* field the builder never sets is not "left alone" — it is written as its default. That is #754's
|
||||
* mechanism: a hand-maintained mirror drifts from a DTO by one field, the write returns HTTP 200,
|
||||
* and the loss surfaces hours later. See `testing.full-replace-asserts-field-list`, whose "Residue"
|
||||
* paragraph filed this gap.
|
||||
* and the loss surfaces hours later. See `testing.full-replace-asserts-field-list`.
|
||||
*
|
||||
* ## Why the compiler was not already catching it
|
||||
* This is not hypothetical. Measured 2026-08-22, before this change: deleting
|
||||
* `weight: clampWeight(item.weight)` from `MultiCollectionsScreen.toItemRequest` typechecked
|
||||
* CLEAN, and that PUT replaces the item list — so every weight would have reset to 1 on the next
|
||||
* save. The screen carries a prose comment warning about exactly that; a comment is not a check.
|
||||
* `FFmpegProfilesScreen` had the same exposure on `qsvPreferNativeDecoder`.
|
||||
*
|
||||
* It was, but only by accident of how the generator emits. `scripts/generate-openapi-types.mjs`
|
||||
* currently renders a nullable DTO property as a REQUIRED member of a nullable type
|
||||
* (`"name": null | string`) rather than an OPTIONAL one (`"name"?: string`). A required member
|
||||
* cannot be omitted, so today every builder is checked. Verified 2026-08-22: none of the request
|
||||
* schemas these builders target (`ScheduleItemRequest`, `ReplaceBlockRequest`, `BlockItemRequest`,
|
||||
* `ReplaceDecoTemplateRequest`, `DecoTemplateItemRequest`, `ReplaceTemplateRequest`,
|
||||
* `TemplateItemRequest`, `ReplacePlaylistRequest`, `PlaylistItemRequest`,
|
||||
* `PlayoutAlternateScheduleItemRequest`, `PlayoutTemplateItemRequest`) declares a single `?:`
|
||||
* member. Optional members DO occur elsewhere in the same generated file (the Auto-Tune
|
||||
* lineup-request family), so this is a property of which DTOs have been modelled so far, not a
|
||||
* guarantee of the generator.
|
||||
* ## What determines whether the compiler can see it
|
||||
*
|
||||
* That makes the protection CONTINGENT: the day one of those DTOs gains a genuinely optional
|
||||
* property, `tsc` goes silent on it — by design, optional means omittable — and the silent drop is
|
||||
* live with no other net watching. `Complete<T>` removes the contingency by requiring every member
|
||||
* at the construction site regardless of how the generator emitted it.
|
||||
* A member is omittable exactly when the generated type marks it `?:`, and that comes from the
|
||||
* `required` array of the schema in `ErsatzTV/wwwroot/openapi/v1.json`.
|
||||
* `scripts/generate-openapi-types.mjs` is a pure pass-through — its whole contribution is
|
||||
* `const optional = required.has(name) ? '' : '?'` — so the determinant is the ASP.NET-produced
|
||||
* OpenAPI document, NOT the generator script. A property lands outside `required` because of how
|
||||
* its DTO is modelled (`weight` and `qsvPreferNativeDecoder` are the two live cases today), which
|
||||
* is why "no optional members exist yet" is never a safe assumption to build on: it is a fact
|
||||
* about which DTOs have been written so far, and it is already false.
|
||||
*
|
||||
* Note the direction of the trap: a nullable property usually emits as REQUIRED-and-nullable
|
||||
* (`"name": null | string`), so most builders are checked and the gap looks closed on inspection.
|
||||
* The unchecked ones are a small minority hiding inside a large majority of checked ones.
|
||||
*
|
||||
* ## Both directions
|
||||
*
|
||||
@@ -36,9 +37,11 @@
|
||||
* does so wherever the value is assigned, including through a spread or an inferred local.
|
||||
* - PHANTOM (a field the builder sets that the schema does not accept) — TypeScript's excess
|
||||
* property check already reports this, but ONLY for a "fresh" object literal in a typed
|
||||
* position. So each construction site also carries an explicit `Complete<…>` annotation rather
|
||||
* than relying on inference from an argument position two calls away; that is what keeps the
|
||||
* literal fresh and this direction live.
|
||||
* position. Returning a literal from a generic `.map` callback is NOT such a position: `map<U>`
|
||||
* infers `U` FROM the callback's return, so the target element type never contextually types the
|
||||
* literal, and the check does not fire — with or without a spread in it. Measured on the
|
||||
* pre-#807 tree: five of the nine construction sites accepted a phantom field. Annotating each
|
||||
* site's return type is what restores this direction.
|
||||
*
|
||||
* ## Explicit `undefined` is still allowed, deliberately
|
||||
*
|
||||
@@ -46,12 +49,13 @@
|
||||
* not to forbid omitting a value, it is to forbid omitting the DECISION — an unmentioned field is
|
||||
* an oversight, `field: undefined` is a choice a reviewer can see.
|
||||
*
|
||||
* ## Shallow on purpose
|
||||
* ## Shallow, and what that costs
|
||||
*
|
||||
* `Complete<T>` does not recurse into `items: Array<ItemRequest>`. A deep variant would have to
|
||||
* distinguish arrays, unions with `null`, and branded enum aliases, and would mangle them. Every
|
||||
* nested item builder is a function in its own right here, so each is annotated
|
||||
* `Complete<ItemRequest>` directly. A NEW nested request type therefore needs its own annotation;
|
||||
* nothing forces that, and that residue is stated rather than implied closed (issue #807).
|
||||
* `Complete<T>` does not recurse into `items: Array<ItemRequest>`; each nested item builder is
|
||||
* annotated `Complete<ItemRequest>` directly instead. This is a scope choice, not a claim that a
|
||||
* deep variant is infeasible — probed 2026-08-22, the shallow mapped form distributes correctly
|
||||
* over unions, leaves `number[]` an array, preserves `readonly`, and passes an index signature
|
||||
* through, so a deep variant is not obviously blocked. A NEW nested request type therefore needs
|
||||
* its own annotation and nothing forces that; see the residue noted on the decision record.
|
||||
*/
|
||||
export type Complete<T> = { [K in keyof Required<T>]: T[K] };
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { Complete } from './completeRequest';
|
||||
import { ApiError, request } from './client';
|
||||
import type { components } from './generated/v1';
|
||||
|
||||
@@ -42,7 +43,7 @@ export function deleteDeco(id: number): Promise<void> {
|
||||
return request<void>(`/api/v1/decos/${id}`, { method: 'DELETE' });
|
||||
}
|
||||
|
||||
export function replaceDeco(id: number, body: ReplaceDecoRequest): Promise<Deco> {
|
||||
export function replaceDeco(id: number, body: Complete<ReplaceDecoRequest>): Promise<Deco> {
|
||||
return request<Deco>(`/api/v1/decos/${id}`, { body, method: 'PUT' });
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { Complete } from './completeRequest';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import {
|
||||
createFFmpegProfile,
|
||||
@@ -19,7 +20,7 @@ function noContent(): Response {
|
||||
return new Response(null, { status: 204 });
|
||||
}
|
||||
|
||||
const sampleRequest: CreateFFmpegProfileRequest = {
|
||||
const sampleRequest: Complete<CreateFFmpegProfileRequest> = {
|
||||
allowBFrames: false,
|
||||
audioBitrate: 192,
|
||||
audioBufferSize: 384,
|
||||
@@ -28,6 +29,7 @@ const sampleRequest: CreateFFmpegProfileRequest = {
|
||||
audioSampleRate: 48,
|
||||
bitDepth: 'EightBit',
|
||||
deinterlaceVideo: false,
|
||||
qsvPreferNativeDecoder: true,
|
||||
hardwareAcceleration: 'None',
|
||||
name: 'New',
|
||||
normalizeAudio: true,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { Complete } from './completeRequest';
|
||||
import { ApiError, request } from './client';
|
||||
import type { components } from './generated/v1';
|
||||
|
||||
@@ -18,7 +19,7 @@ export function createFFmpegProfile(body: CreateFFmpegProfileRequest): Promise<F
|
||||
return request<FFmpegProfileDetail>('/api/v1/ffmpeg/profiles', { body, method: 'POST' });
|
||||
}
|
||||
|
||||
export function updateFFmpegProfile(id: number, body: UpdateFFmpegProfileRequest): Promise<FFmpegProfileDetail> {
|
||||
export function updateFFmpegProfile(id: number, body: Complete<UpdateFFmpegProfileRequest>): Promise<FFmpegProfileDetail> {
|
||||
return request<FFmpegProfileDetail>(`/api/v1/ffmpeg/profiles/${id}`, { body, method: 'PUT' });
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ export * from './channels';
|
||||
export * from './channelTemplates';
|
||||
export * from './client';
|
||||
export * from './collections';
|
||||
export * from './completeRequest';
|
||||
export * from './dashboard';
|
||||
export * from './decos';
|
||||
export * from './decoTemplates';
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { Complete } from './completeRequest';
|
||||
import { ApiError, request } from './client';
|
||||
import type { components } from './generated/v1';
|
||||
import type { RemoteFamily } from '../mediaSources/familyMeta';
|
||||
@@ -101,7 +102,7 @@ export function getRemoteLibraries(family: RemoteFamily, sourceId: number): Prom
|
||||
export function replaceRemoteLibraryPreferences(
|
||||
family: RemoteFamily,
|
||||
sourceId: number,
|
||||
body: ReplaceRemoteLibraryPreferencesRequest
|
||||
body: Complete<ReplaceRemoteLibraryPreferencesRequest>
|
||||
): Promise<RemoteLibrary[]> {
|
||||
return request<RemoteLibrary[]>(`/api/v1/media-sources/${family}/${sourceId}/libraries`, { body, method: 'PUT' });
|
||||
}
|
||||
@@ -113,7 +114,7 @@ export function getPathReplacements(family: RemoteFamily, sourceId: number): Pro
|
||||
export function replacePathReplacements(
|
||||
family: RemoteFamily,
|
||||
sourceId: number,
|
||||
body: ReplacePathReplacementsRequest
|
||||
body: Complete<ReplacePathReplacementsRequest>
|
||||
): Promise<PathReplacement[]> {
|
||||
return request<PathReplacement[]>(`/api/v1/media-sources/${family}/${sourceId}/path-replacements`, {
|
||||
body,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { Complete } from './completeRequest';
|
||||
import { ApiError, request, requestWithMeta, type ResponseWithMeta } from './client';
|
||||
import type { components } from './generated/v1';
|
||||
|
||||
@@ -53,7 +54,7 @@ export function createMultiCollection(body: CreateMultiCollectionRequest): Promi
|
||||
*/
|
||||
export function updateMultiCollection(
|
||||
id: number,
|
||||
body: UpdateMultiCollectionRequest,
|
||||
body: Complete<UpdateMultiCollectionRequest>,
|
||||
ifMatch?: string | null
|
||||
): Promise<ResponseWithMeta<MultiCollection>> {
|
||||
return requestWithMeta<MultiCollection>(`/api/v1/multi-collections/${id}`, {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { Complete } from '../api/completeRequest';
|
||||
import { useCallback, useEffect, useRef, useState, type ReactNode } from 'react';
|
||||
import { ArrowLeft, Check, Copy, Plus, SlidersHorizontal, Trash2, TriangleAlert } from 'lucide-react';
|
||||
import { navigateToPath } from '../routing';
|
||||
@@ -24,7 +25,11 @@ const BASE_PATH = '/app/ffmpeg-profiles';
|
||||
// form must not offer one it would silently override (ersatztv#529)
|
||||
const MINIMUM_QSV_EXTRA_HARDWARE_FRAMES = 64;
|
||||
|
||||
type Draft = CreateFFmpegProfileRequest;
|
||||
// `Complete<…>` so the draft must name every request member: the edit path PUTs this whole
|
||||
// object to a full-replace endpoint, where an unset member is written as its default rather
|
||||
// than left alone. `qsvPreferNativeDecoder` is optional in the schema and both draft builders
|
||||
// happened to set it; nothing required them to (#807).
|
||||
type Draft = Complete<CreateFFmpegProfileRequest>;
|
||||
|
||||
/* ---------- enum option lists (mirror ErsatzTV/Pages/FFmpegEditor.razor) ---------- */
|
||||
|
||||
|
||||
@@ -16,8 +16,10 @@ import {
|
||||
type MediaCollection,
|
||||
type MultiCollection,
|
||||
type MultiCollectionItemRequest,
|
||||
type SmartCollection
|
||||
type SmartCollection,
|
||||
type UpdateMultiCollectionRequest
|
||||
} from '../api';
|
||||
import type { Complete } from '../api/completeRequest';
|
||||
|
||||
/* ---------- data hook ---------- */
|
||||
|
||||
@@ -137,7 +139,7 @@ function itemsFromMultiCollection(mc: MultiCollection): DraftItem[] {
|
||||
);
|
||||
}
|
||||
|
||||
function toItemRequest(item: DraftItem): MultiCollectionItemRequest {
|
||||
function toItemRequest(item: DraftItem): Complete<MultiCollectionItemRequest> {
|
||||
return {
|
||||
collectionId: item.kind === 'manual' ? item.id : null,
|
||||
playbackOrder: 'Chronological',
|
||||
@@ -277,7 +279,10 @@ function MultiCollectionEditor({
|
||||
setSaveError(null);
|
||||
|
||||
try {
|
||||
const body = { items: items.map(toItemRequest), name: trimmedName };
|
||||
const body: Complete<UpdateMultiCollectionRequest> = {
|
||||
items: items.map(toItemRequest),
|
||||
name: trimmedName
|
||||
};
|
||||
if (initial) {
|
||||
await updateMultiCollection(initial.id, body, etagRef.current);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user