Usage with Brownie package

The brownfield codegen CLI command generates @callstack/brownie (Brownie) state management library native store types from TypeScript schema.

Usage

brownfield codegen          # Generate Swift types
brownfield codegen -p swift # Generate Swift only
brownfield codegen --help   # Show help for Brownie state management codegen
brownfield --version        # Show version

Store Definition

Stores are auto-discovered from *.brownie.ts files. Define your store shape using module augmentation:

// BrownfieldStore.brownie.ts
import type { BrownieStore } from '@callstack/brownie';

interface BrownfieldStore extends BrownieStore {
  counter: number;
  user: string;
  isLoading: boolean;
}

declare module '@callstack/brownie' {
  interface BrownieStores {
    BrownfieldStore: BrownfieldStore;
  }
}

Multiple stores in same file:

// Stores.brownie.ts
import type { BrownieStore } from '@callstack/brownie';

interface UserStore extends BrownieStore {
  name: string;
  email: string;
}

interface SettingsStore extends BrownieStore {
  theme: 'light' | 'dark';
  notificationsEnabled: boolean;
}

declare module '@callstack/brownie' {
  interface BrownieStores {
    UserStore: UserStore;
    SettingsStore: SettingsStore;
  }
}

Generated Output

Swift (Codable struct with mutable properties):

struct BrownfieldStore: Codable {
    var counter: Double
    var isLoading: Bool
    var user: String
}

Swift files are always generated to node_modules/@callstack/brownie/ios/Generated/. This path is auto-resolved and not configurable.

Store Discovery

  1. Recursively finds *.brownie.ts files (skips node_modules)
  2. Parses declare module '@callstack/brownie' blocks using ts-morph
  3. Extracts store names from BrownieStores interface properties
  4. Validates no duplicate store names exist

Codegen Pipeline

*.brownie.ts files (auto-discovered)


ts-morph (parse BrownieStores interface)


quicktype-typescript-input (schemaForTypeScriptSources)


JSON Schema


quicktype-core

       └──▶ Swift (lang: 'swift', mutable-properties: true)

Need React or React Native expertise you can count on?