Commit 627e534
authored
feat(cli): port backups list and restore to native TypeScript (#5331)
## Summary
Replaces the Phase-0 Go-proxy handlers for `supabase backups list` and
`supabase backups restore` with native Effect-based implementations.
Adds the supporting legacy infrastructure (`legacy/auth`,
`legacy/config`, project-ref resolver, Glamour table renderer) that
subsequent ports will reuse.
## Highlights
- **Strict Go parity on the wire.** Byte-identical `--output json`
(alphabetical struct-field order, `backups: null` for empty slices to
match Go's nil-slice semantics), Glamour-styled tables verified
byte-for-byte against Go test fixtures, restore stderr line preserved.
- **`Output.raw(text, stream)` service method.** Handlers now route
stdout/stderr writes through the `Output` service instead of calling
`process.stdout/stderr.write` directly. `mockOutput` captures these into
`rawChunks` + `stdoutText` / `stderrText` getters, eliminating ~30 lines
of `process.*.write` monkey-patching per integration test file.
- **Shared backups infrastructure.** New `backups.layers.ts` exposes a
`legacyBackupsRuntimeLayer(subcommand)` factory so each subcommand wires
the platform-API + project-ref stack identically. New
`mapLegacyBackupHttpError` factory in `backups.errors.ts` consolidates
`RESPONSE_ERROR_TAGS` + HTTP-error dispatch and truncates response
bodies to 1024 chars before embedding them in tagged errors.
- **Flag-type discipline.** Both `*.command.ts` files mark `config as
const` and `export type LegacyBackups*Flags =
CliCommand.Command.Config.Infer<typeof config>` (canonical
`login.command.ts` pattern); handlers import the type instead of
duplicating private interfaces.
- **Spinner suppressed in non-text modes.** `output.task("Fetching
backups...")` / `"Initiating PITR restore..."` only run when
`output.format === "text"`, eliminating dangling `[task] start:` lines
on stderr in JSON / stream-json modes.
- **API contracts regenerated.**
`packages/api/src/generated/contracts.ts` rebuilt from upstream OpenAPI
— adds the missing `id` field on backup items, plus broader spec drift
since the last sync.
- **Tests + checks pass.** Unit + integration suites green, including
the new `backups.encoders.unit.test.ts` and the byte-stable `--output
json` assertion (against the Go fixture from
`apps/cli-go/internal/backups/list/list_test.go`). Targeted e2e `--help`
smoke tests for both `list` and `restore`.
## Known Gaps (documented, not blocking)
- `V1RestorePitrBackupInput.recovery_time_target_unix` retains an
upstream `>= 0` constraint that Go's `int64` does not enforce. A
negative timestamp surfaces a local schema-decode error rather than the
API's own error. Noted in `restore/SIDE_EFFECTS.md`; resolving requires
an upstream OpenAPI change.
## Reviewer Notes
- The handlers do not log any token, error body, or response field that
isn't already part of the documented Go output. Bodies are capped at
1024 chars even though the Management API is trusted, to set the right
precedent for future ports against less-trusted endpoints.
- The OpenAPI regen also touches `effect-client.ts` and `openapi.json`.
Diff scope is large but mechanical — all the meaningful schema deltas
land in `contracts.ts`. One unrelated `next/` snapshot expectation
(`platform-schema.integration.test.ts`) updated to match the new
upstream description text for `v1ListAllProjects`.
Closes CLI-13011 parent 56b598b commit 627e534
51 files changed
Lines changed: 4622 additions & 522 deletions
File tree
- apps/cli
- docs
- src
- legacy
- auth
- commands/backups
- list
- restore
- config
- output
- telemetry
- next/commands/platform
- tests/helpers
- packages
- api/src/generated
- cli-test-helpers/src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
91 | 102 | | |
92 | 103 | | |
93 | 104 | | |
| |||
139 | 150 | | |
140 | 151 | | |
141 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
142 | 168 | | |
143 | 169 | | |
144 | 170 | | |
| |||
192 | 218 | | |
193 | 219 | | |
194 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
195 | 242 | | |
196 | 243 | | |
197 | 244 | | |
| |||
206 | 253 | | |
207 | 254 | | |
208 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
209 | 274 | | |
210 | 275 | | |
211 | 276 | | |
| |||
311 | 376 | | |
312 | 377 | | |
313 | 378 | | |
| 379 | + | |
314 | 380 | | |
315 | 381 | | |
316 | 382 | | |
| |||
0 commit comments