Skip to content

feat(cli): port services#5468

Merged
Coly010 merged 3 commits into
supabase:developfrom
7ttp:feat/services-native
Jun 5, 2026
Merged

feat(cli): port services#5468
Coly010 merged 3 commits into
supabase:developfrom
7ttp:feat/services-native

Conversation

@7ttp
Copy link
Copy Markdown
Contributor

@7ttp 7ttp commented Jun 4, 2026

TL;DR

ports supabase services to native ts

What’s introduced

adds native TS implementations for services
moves the local service version rendering and linked version lookup into shared command logic,
adds integration coverage for text/json output and linked version fallback behavior

Ref

  • closes CLI-1307

@7ttp 7ttp requested a review from a team as a code owner June 4, 2026 08:55
@7ttp 7ttp self-assigned this Jun 4, 2026
@7ttp 7ttp force-pushed the feat/services-native branch from b0df251 to 9c2dcbd Compare June 4, 2026 09:12
@7ttp 7ttp force-pushed the feat/services-native branch from 9c2dcbd to a079484 Compare June 4, 2026 09:24
- Authenticate tenant probes with apikey-only for new-style `sb_` keys
  (drops the bearer header), matching the Go service gateway and the
  existing legacy tenant-version probes; older JWT keys still send both.
- Wrap the fetched service-role key in `Redacted` end-to-end so it cannot
  leak through Effect failure traces.
- Validate the project ref against `^[a-z]{20}$` before it reaches the
  management API path param or the tenant gateway hostname, preventing
  host/path injection of the service-role key.
- Read the ambient HttpClient from context instead of self-provisioning
  `FetchHttpClient.layer`, so legacy `--debug` HTTP logging covers the
  linked-version lookups; the next command now provides its own transport.
- Defer Go `--output pretty` to the TS `--output-format` flag in the legacy
  handler so `--output pretty --output-format json` emits JSON (CLI-1546).
- Write the linked-project cache via `Effect.ensuring(linkedProjectCache.cache(ref))`
  to match Go's PersistentPostRun, keeping PostHog org/project groups attached.
- Hoist the duplicated warning formatter into the shared module and align
  the next user-agent with the other native commands.
- Mark the legacy `services` command as `ported` in the porting-status doc,
  expand integration coverage (pretty+json, stream-json, linked merge with
  warning) and add unit coverage for the sb_ auth guard and ref validation.
Copy link
Copy Markdown
Contributor

@Coly010 Coly010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@Coly010 Coly010 merged commit efa6df7 into supabase:develop Jun 5, 2026
12 checks passed
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;

const projectRefPath = path.join(cliConfig.workdir, "supabase", ".temp", "project-ref");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion(non-blocking): use LegacyProjectRefResolver.resolveOptional here instead of re-reading .temp/project-ref inline. It already does this projectId/ref-file chain via legacyTempPaths() and mirrors Go's flags.LoadProjectRef.

readonly userAgent: string;
readonly headers?: Readonly<Record<string, string | undefined>>;
readonly api?: ApiClient;
readonly tenantBaseUrlOverride?: string;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note(non-blocking): tenantBaseUrlOverride bypasses the PROJECT_REF_PATTERN guard. Test-only today, but it sits on an exported type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants