Shared TypeScript types and transform utilities for BarnTeq edge and cloud services.
npm install github:BarnTeq/barnteq-types#v1.0.2import {
// Types
type Command,
type BarnConfig,
type SyncRequest,
type DeviceReading,
// Transform utilities
unixToIso,
isoToUnix,
snakeToCamel,
camelToSnake,
} from '@barnteq/types';Command- Base command structureCommandAction- Command action enum ('unlock_gate', 'lock_gate', 'toggle_light', etc.)CommandStatus- Command status enum ('pending', 'acknowledged', 'completed', 'failed')AcknowledgeCommandRequest- Request to acknowledge command completionCloudCommand- Extended command with delivery method
BarnConfig- Full barn configurationBarnConfigStall- Stall configurationBarnConfigHorse- Horse profileBarnConfigCamera- Camera configurationBarnConfigFloorplan- Floorplan with device positions
SyncRequest- Edge-to-cloud sync requestSyncResponse- Cloud-to-edge sync responseHeartbeatRequest- Edge heartbeat requestHeartbeatResponse- Cloud heartbeat response
Device- Device/sensor configurationDeviceReading- Sensor reading dataReadingType- Reading type union. Core sensor types (state,level,temperature,humidity,battery,water_level,feed_level,motion,smoke,co, etc.) plus VLM-derived stall state (stall_occupancy,feed_status,waste_detected,horse_pose,bedding_condition,stall_state_raw). Full list insrc/device.ts.EDGE_SENSOR_TO_DEVICE_TYPE- Mapping from edge sensor types to cloud device types
EventLog- Event log entryEventLogType- Event type enum
ApiError- Standard API error structureAPI_ERROR_CODES- Error code constants
// Unix timestamp (seconds) to ISO string
unixToIso(1234567890); // "2009-02-13T23:31:30.000Z"
// ISO string to Unix timestamp (seconds)
isoToUnix("2009-02-13T23:31:30.000Z"); // 1234567890
// Date to ISO string
dateToIso(new Date()); // "2025-01-01T00:00:00.000Z"
// ISO string to Date
isoToDate("2025-01-01T00:00:00.000Z"); // Date object// Minutes to seconds
minutesToSeconds(5); // 300
// Seconds to minutes
secondsToMinutes(300); // 5// Snake case to camel case
snakeToCamel({ barn_id: '123', device_type: 'sensor' });
// { barnId: '123', deviceType: 'sensor' }
// Camel case to snake case
camelToSnake({ barnId: '123', deviceType: 'sensor' });
// { barn_id: '123', device_type: 'sensor' }// Birth date to age in years
birthDateToAge("2020-01-15"); // 5 (as of 2025)
// Age to approximate birth date
ageToBirthDate(5); // "2020-01-01"// Transform edge reading for cloud API
transformReadingToCloud({
edgeDeviceId: 'stall_1_gates_1',
readingType: 'state',
valueText: 'open',
timestamp: 1234567890
});
// Transform cloud reading for edge storage
transformReadingToEdge(cloudReading);- barnteq-edge - Edge service for NVIDIA Jetson devices
- barnteq-cloud - Cloud backend (Next.js)
# Install dependencies
npm install
# Build
npm run buildThis package is installed via git URL. Since git dependencies don't run npm scripts, the dist/ directory is committed to the repository.
UNLICENSED - BarnTeq Inc.