Documentation
¶
Overview ¶
Package supabase implements the Supabase → nSelf migration pipeline.
It connects to a Supabase project via PostgREST + the service_role key, pulls schema, data, auth users, and storage buckets, then generates nSelf-compatible Drizzle migration SQL files, Hasura metadata YAML, an auth user import script, and a human-readable next-steps summary.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthUser ¶
type AuthUser struct {
ID string `json:"id"`
Email string `json:"email"`
Phone string `json:"phone"`
EmailConfirmed bool `json:"email_confirmed_at"`
CreatedAt string `json:"created_at"`
}
AuthUser represents a minimal view of a Supabase auth.users row.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the Supabase REST APIs.
func (*Client) PullAuthUsers ¶
PullAuthUsers fetches up to 1 000 users from the Supabase Admin auth API.
func (*Client) PullRLSPolicies ¶
PullRLSPolicies fetches RLS policies from the Supabase project by executing a query against pg_policies via the Supabase Management API SQL endpoint.
The Management API endpoint is:
POST https://api.supabase.com/v1/projects/{ref}/database/query
Authorization: Bearer <service_role_key>
Content-Type: application/json
{"query": "<SQL>"}
If the Management API is unreachable or returns an auth error, an empty slice is returned along with an informational error so the caller can include a manual-review note in the generated migration SQL.
func (*Client) PullSchema ¶
PullSchema fetches tables and columns from the Supabase project. It uses the PostgREST OpenAPI endpoint which returns schema information.
func (*Client) PullStorageBuckets ¶
func (c *Client) PullStorageBuckets(ctx context.Context) ([]StorageBucket, error)
PullStorageBuckets fetches all storage buckets from the Supabase Storage API.
type Config ¶
type Config struct {
ProjectRef string // e.g. "abcdefghijklmnopqrst"
ServiceKey string // service_role JWT
}
Config holds the credentials for one Supabase project.
type GeneratedArtifacts ¶
type GeneratedArtifacts struct {
// MigrationSQL is the Drizzle-compatible SQL migration file content.
MigrationSQL string
// HasuraMetadata is the Hasura metadata YAML for the pulled schema.
HasuraMetadata string
// AuthImportScript is a shell script that imports users into nSelf.
AuthImportScript string
// Summary is a human-readable text summary with next steps.
Summary string
}
GeneratedArtifacts contains the files the generator produced in memory (keyed by relative output path).
func Generate ¶
func Generate(projectRef string, r *PullResult) *GeneratedArtifacts
Generate converts a PullResult into nSelf-compatible artifacts.
type PullResult ¶
type PullResult struct {
Tables []Table
Policies []RLSPolicy
Users []AuthUser
Buckets []StorageBucket
}
PullResult contains everything pulled from a Supabase project.
type RLSPolicy ¶
type RLSPolicy struct {
TableSchema string
TableName string
PolicyName string
Command string // SELECT | INSERT | UPDATE | DELETE | ALL
Permissive bool
Roles []string
Using string
WithCheck string
}
RLSPolicy is a PostgreSQL row-level security policy captured from the information_schema via PostgREST.