API & server functions

MigrateTo's app code calls server functions defined in src/lib/*.functions.ts. They're typed RPCs over HTTP; every authenticated call carries your session bearer.

Calling a server function from the client

import { useServerFn } from '@tanstack/react-start'
import { getMyProfile } from '@/lib/profile.functions'

const fetchProfile = useServerFn(getMyProfile)
const { data } = useQuery({ queryKey: ['profile'], queryFn: fetchProfile })

Authentication

  • Every function wrapped with requireSupabaseAuth needs a valid bearer token (added automatically by our client).
  • Public functions live under /api/public/* file routes and verify signatures themselves (webhooks, callbacks).
  • Role checks use the has_any_role RPC; client cannot bypass.

Reference

Profile — src/lib/profile.functions.ts

  • getMyProfile · GET · returns display name, avatar URL (signed), email.
  • updateMyProfile · POST · { displayName?, avatarPath? }.
  • createAvatarUploadUrl · POST · returns a signed URL to upload directly to storage.
  • getNotificationPrefs / updateNotificationPrefs.
  • listMyWorkspaces · GET · workspaces + your role on each.

Workspaces — src/lib/workspaces.functions.ts

  • listWorkspaces, createWorkspace, updateWorkspace, deleteWorkspace.

Members — src/lib/members.functions.ts

  • listMembers, inviteMember, updateMemberRole, removeMember.

Figma — src/lib/figma.functions.ts + figma-oauth.functions.ts

  • setFigmaPAT, testFigmaConnection, importFigmaFile, reingestFigmaFile.

Dataverse — src/lib/dataverse.functions.ts

  • setDataverseConnection, testDataverseConnection, syncTables, listTables, listColumns.

Mapping & generation

  • mappings.functions.tssaveBinding, listBindings, deleteBinding.
  • mapping-templates.functions.tssaveTemplate, applyTemplate.
  • generation.functions.tsstartGeneration, getTask, cancelTask, listRecent.

Packages & deploy

  • packages.functions.tsbuildPackage, getDownloadUrl, listPackages.
  • deploy.functions.ts — pipeline scaffolding only; actual deploy is run by your CLI / pipeline.

SSO, security, audit

  • sso.functions.tsprovisionConnection, verifyDomain, listInvitations, enforceSSO.
  • security.functions.tsgetSecurityPolicy, updateSecurityPolicy, getSecurityPosture.
  • audit.functions.tslistAuditEvents, exportAuditCsv.

Billing & usage

  • billing.functions.tsgetBillingStatus, createCheckoutSession.
  • usage.functions.tsgetUsage, getCreditHistory.

Developer & misc

  • developer.functions.ts — API tokens, webhook secrets.
  • comments.functions.ts — preview comments.
  • review.functions.ts — review packets.
  • components.functions.ts — Figma component catalog.
Source is the spec
We don't publish an OpenAPI document; the source files are the canonical reference and TypeScript types are exported. Browse src/lib/*.functions.ts in your IDE for exact input/output shapes.
Was this page helpful?Send feedback →