@paywithpull/sanity-schema
v0.1.4
Published
PULL Sanity content schema artifacts: extracted schema.json and generated TypeScript types
Readme
@paywithpull/sanity-schema
Generated artifacts from the PULL Sanity Studio (apps/sanity-studio in the pull monorepo):
schema.json— the extracted schema (input for Sanity TypeGen)sanity.types.ts— TypeScript types for every document and object type
Do not edit these files by hand. The schema source of truth is apps/sanity-studio/schemaTypes.
Run bun run generate here (or bun run typegen in apps/sanity-studio) to regenerate, and CI
republishes automatically when the schema changes on main.
This is a public package — no npm auth needed to install it. It contains only the content schema (structure), never content or credentials. If app-specific content types are added later whose shape shouldn't be public, split those into a separate private package rather than flipping this one.
Using the document types
import type {Post, Author} from '@paywithpull/sanity-schema'Generating query-result types in a consumer repo (recommended)
Document types alone don't describe what your GROQ projections return. Run TypeGen in the
consumer repo against this package's schema.json to get exact per-query result types:
// sanity.cli.ts (in the consumer repo; `sanity` must be a devDependency)
import {defineCliConfig} from 'sanity/cli'
export default defineCliConfig({
typegen: {
path: './src/**/*.{ts,tsx}',
schema: './node_modules/@paywithpull/sanity-schema/schema.json',
generates: './src/sanity/sanity.types.ts',
overloadClientMethods: true,
},
})Then, after schema or query changes:
sanity typegen generateQueries defined with defineQuery get typed automatically through client.fetch().
