Skip to content

feat(datasource): read-only introspection routes + by-name test for Studio sync#2085

Merged
xuyushun441-sys merged 2 commits into
mainfrom
feat/datasource-sync
Jun 21, 2026
Merged

feat(datasource): read-only introspection routes + by-name test for Studio sync#2085
xuyushun441-sys merged 2 commits into
mainfrom
feat/datasource-sync

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

Summary

Expose the existing external-datasource introspection service over REST so Studio can list a datasource's remote tables and preview the object definition each would become — the backend half of "sync objects from a datasource".

  • GET /api/v1/datasources/:name/remote-tableslistRemoteTables()
  • POST /api/v1/datasources/:name/object-draftgenerateObjectDraft(table)

Both are read-only (introspect + type-map, no persistence). The Studio caller creates the resulting object through the normal metadata channel (object is create-only at runtime), keeping object-creation in the sanctioned path rather than importObject (which requires a writable store not wired here). Degrade to 503 when the service isn't wired; 400 when table is missing.

Verification

Verified live against a fresh showcase backend with a seeded SQLite datasource (customers/orders): remote-tables lists both with column counts; object-draft for customers yields { name, fields: [id,name,email,created_at], external:{remoteName} }. Unit tests cover both routes (list + draft 200 / 400-without-table); service-datasource admin-routes suite green (8/8).

🤖 Generated with Claude Code

Expose the external-datasource introspection service over REST so Studio can
list a datasource's remote tables and preview the object definition they would
become:

- GET  /api/v1/datasources/:name/remote-tables  → listRemoteTables()
- POST /api/v1/datasources/:name/object-draft    → generateObjectDraft(table)

Both are read-only (introspect + type-map; no persistence) — the caller creates
the object through the normal metadata channel. Degrade to 503 when the
external-datasource service isn't wired; 400 when the table is missing.

Verified live against a seeded SQLite datasource (customers/orders →
remote-tables lists both; object-draft yields a typed object definition).
Tests: remote-tables list + object-draft (200 + 400-without-table).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 21, 2026 3:36am

Request Review

@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): packages/services.

5 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/guides/packages.mdx (via packages/services)
  • content/docs/guides/runtime-services/audit-service.mdx (via packages/services)
  • content/docs/guides/runtime-services/index.mdx (via packages/services)
  • content/docs/guides/runtime-services/settings-service.mdx (via packages/services)
  • content/docs/protocol/objectos/i18n-standard.mdx (via packages/services)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

The `datasource` `test_connection` action declares `POST /datasources/:id/test`
(probe a saved datasource by name), but the admin routes only implemented
`POST /datasources/test` (probe an unsaved inline draft). The action — and any
UI that wires it (the Studio datasource manager) — hit a 404.

Add a thin by-name route backed by a new `ExternalDatasourceService.testConnection(name)`
that times a live introspect (driver connect + schema read) and returns
`{ ok, latencyMs, tableCount }` or `{ ok:false, error }`. Reuses the same wired
introspection pool as remote-tables/object-draft, so the secret is resolved
through the existing path — the route never handles cleartext. Registered before
the generic `:name` mutation routes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@xuyushun441-sys xuyushun441-sys changed the title feat(datasource): read-only introspection routes for Studio sync feat(datasource): read-only introspection routes + by-name test for Studio sync Jun 21, 2026
@github-actions github-actions Bot added size/m and removed size/s labels Jun 21, 2026
@xuyushun441-sys
xuyushun441-sys merged commit 124959e into main Jun 21, 2026
16 checks passed
@xuyushun441-sys
xuyushun441-sys deleted the feat/datasource-sync branch June 21, 2026 03:42
xuyushun441-sys added a commit that referenced this pull request Jun 21, 2026
…tion (#2112)

The README mentioned "REST routes under /api/v1/datasources" but didn't
enumerate them, and predated the Studio integration. Add:
- a REST routes section (lifecycle + drivers catalog + by-name test + GET :name
  detail + introspection/sync routes), with the credential-split note;
- a Studio integration section: datasource is managed through the metadata-admin
  engine (Setup → Integrations → Datasources), runtime records persist to
  sys_metadata and rehydrate on restart.

Reflects #2083 (drivers), #2085 (remote-tables/object-draft/by-name test),
#2086 (GET :name), #2091 (Setup nav), #2096 (persistence).

Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants