hypercard-shared-validators
v1.0.0
Published
Shared validators and types for Hypercard frontend and backend
Readme
@hypercard/shared
Shared validators and types for Hypercard frontend and backend applications.
Installation
yarn add @hypercard/shared
# or
npm install @hypercard/sharedUsage
Importing validators
import { expenseValidator, messageValidator } from "@hypercard/shared";
// Validate expense data
const expense = expenseValidator.parse(expenseData);Importing types only
import type { Expense, ServerMessage } from "@hypercard/shared/types";
// Use types for type annotations
const handleMessage = (message: ServerMessage) => {
// ...
};Available Validators
- Common: Tool calls, messages, actions, events
- Expense: Expense data, submissions, validation results
- Message: Server message types for real-time communication
- Workflow: Expense workflow state and conversation context
- Websocket: WebSocket event types
- Receipts: Parsed receipt data
- Events: LangGraph events and node names
- Tools: Tool input/output types
Available Constants
ContentType: Text and image content typesRole: User, assistant, system rolesActionType: Tool call and other action typesEventType: Message and action event typesSERVER_MESSAGE_TYPES: All server message type constantsSUGGESTED_ACTIONS: Suggested action typesTarsMessageAction: WebSocket message actionsLANGGRAPH_EVENTS: LangGraph event typesNODE_NAMES: Workflow node names
TypeScript Support
This package is built with TypeScript and provides full type definitions. All validators use Zod for runtime validation with TypeScript inference.
Domain-Driven Design
The validators follow domain-driven design patterns with:
- Arrow named functions using TypeScript
- Default parameters as objects
- Zod validation for type safety
- Const objects over enums for immutability
