@smta/schemas
v0.4.0
Published
Zod schemas for SMTA public.* RPC function contracts
Readme
@smta/schemas
Zod v4 schemas for every public.* RPC function in SMTA (SaaS Multi-Tenant Architecture). Use these to validate inputs before calling SMTA functions and to parse and type the responses.
Install
npm install @smta/schemasUsage
Each RPC function has a corresponding input schema and output schema. Import what you need:
import {
createOrganizationInputSchema,
createOrganizationOutputSchema,
listMyOrganizationsOutputSchema,
type CreateOrganizationInput,
type ListMyOrganizationsItem,
} from '@smta/schemas'
// Validate input before calling the RPC (e.g. in a server action)
const input = createOrganizationInputSchema.parse({
p_name: formData.get('name'),
p_description: formData.get('description'),
})
// Parse and type the RPC response (Supabase example)
const { data, error } = await supabase.rpc('create_organization', input)
const org = createOrganizationOutputSchema.parse(data)
// List organizations
const { data: orgsData } = await supabase.rpc('list_my_organizations')
const orgs: ListMyOrganizationsItem[] = listMyOrganizationsOutputSchema.parse(orgsData)Covered RPC functions
Schemas are provided for all functions in these areas. See the RPC Reference at smta.dev for the full function signatures.
- Organizations —
create_organization,get_organization,list_my_organizations,update_organization,list_organization_members,add_member_to_organization,remove_user_from_organization,transfer_super_admin - Units — create, get, list, update, add/remove members
- User Profile — get and update profile
- Invitations — create, accept, list, revoke
Version compatibility
Schema versions are locked to the SMTA SQL version. Install the same version as your deployed database:
npm install @smta/[email protected] # matches @smta/[email protected] deploymentPart of the SMTA package family
| Package | Purpose |
|---------|---------|
| @smta/core | Adapter-agnostic SQL schema |
| @smta/supabase | Supabase adapter SQL |
| @smta/payload | Payload CMS adapter SQL + middleware |
| @smta/billing | BillingProvider interface (Stripe, Lemon Squeezy) |
| @smta/schemas | This package — Zod v4 schemas for all public.* RPC contracts |
| @smta/cli | Deployment CLI |
License
MIT
