index.d.ts 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. export declare enum OrgStatus {
  2. ACTIVE = "active",
  3. SUSPENDED = "suspended",
  4. TRIAL = "trial"
  5. }
  6. export declare enum ProjectStatus {
  7. PLANNING = "planning",
  8. ACTIVE = "active",
  9. PAUSED = "paused",
  10. COMPLETED = "completed",
  11. ARCHIVED = "archived"
  12. }
  13. export declare enum DeviceStatus {
  14. OFFLINE = "offline",
  15. ONLINE = "online",
  16. CAPTURING = "capturing",
  17. UPLOADING = "uploading",
  18. DEGRADED = "degraded",
  19. UPDATING = "updating",
  20. ERROR = "error"
  21. }
  22. export declare enum DeviceCommandType {
  23. CAPTURE_NOW = "capture_now",
  24. REBOOT = "reboot",
  25. SYNC_CONFIG = "sync_config",
  26. UPDATE_FIRMWARE = "update_firmware",
  27. TRIGGER_UPLOAD = "trigger_upload"
  28. }
  29. export declare enum CaptureStatus {
  30. PENDING = "pending",
  31. UPLOADED = "uploaded",
  32. PROCESSING = "processing",
  33. READY = "ready",
  34. FAILED = "failed"
  35. }
  36. export declare enum VideoStatus {
  37. PENDING = "pending",
  38. PROCESSING = "processing",
  39. READY = "ready",
  40. FAILED = "failed"
  41. }
  42. export declare enum AlertSeverity {
  43. INFO = "info",
  44. WARNING = "warning",
  45. ERROR = "error",
  46. CRITICAL = "critical"
  47. }
  48. export declare enum AlertType {
  49. DEVICE_OFFLINE = "device_offline",
  50. DEVICE_ERROR = "device_error",
  51. STORAGE_FULL = "storage_full",
  52. UPLOAD_FAILED = "upload_failed",
  53. CAPTURE_MISSED = "capture_missed",
  54. VIDEO_FAILED = "video_failed",
  55. FIRMWARE_UPDATE_AVAILABLE = "firmware_update_available"
  56. }
  57. export declare enum UserRole {
  58. SUPER_ADMIN = "super_admin",
  59. ORG_ADMIN = "org_admin",
  60. PROJECT_MANAGER = "project_manager",
  61. VIEWER = "viewer"
  62. }
  63. export declare enum CommandResultStatus {
  64. PENDING = "pending",
  65. DELIVERED = "delivered",
  66. ACKNOWLEDGED = "acknowledged",
  67. SUCCESS = "success",
  68. FAILED = "failed",
  69. TIMEOUT = "timeout"
  70. }
  71. export interface Organization {
  72. id: string;
  73. name: string;
  74. status: OrgStatus;
  75. planTier: string;
  76. createdAt: Date;
  77. updatedAt: Date;
  78. }
  79. export interface User {
  80. id: string;
  81. email: string;
  82. name: string;
  83. avatarUrl: string | null;
  84. provider: 'google' | 'email' | 'api_key';
  85. emailVerified: boolean;
  86. createdAt: Date;
  87. updatedAt: Date;
  88. }
  89. export interface Membership {
  90. userId: string;
  91. orgId: string;
  92. role: UserRole;
  93. invitedBy: string | null;
  94. joinedAt: Date;
  95. }
  96. export interface OrgMember extends User {
  97. role: UserRole;
  98. joinedAt: Date;
  99. }
  100. export interface AuthTokens {
  101. accessToken: string;
  102. refreshToken: string;
  103. expiresIn: number;
  104. }
  105. export interface AuthProvider {
  106. google?: {
  107. accessToken: string;
  108. refreshToken: string;
  109. expiresAt: number;
  110. };
  111. }
  112. export interface Project {
  113. id: string;
  114. orgId: string;
  115. name: string;
  116. description: string | null;
  117. timezone: string;
  118. startDate: Date | null;
  119. endDate: Date | null;
  120. status: ProjectStatus;
  121. captureInterval: number;
  122. resolution: string;
  123. createdAt: Date;
  124. updatedAt: Date;
  125. }
  126. export interface ProjectCreateInput {
  127. name: string;
  128. description?: string;
  129. timezone?: string;
  130. startDate?: string;
  131. endDate?: string;
  132. captureInterval?: number;
  133. resolution?: string;
  134. }
  135. export interface ProjectUpdateInput extends Partial<ProjectCreateInput> {
  136. status?: ProjectStatus;
  137. }
  138. export interface Device {
  139. id: string;
  140. projectId: string;
  141. orgId: string;
  142. serialNo: string;
  143. name: string;
  144. firmwareVersion: string | null;
  145. lastSeenAt: Date | null;
  146. status: DeviceStatus;
  147. config: DeviceConfig;
  148. createdAt: Date;
  149. updatedAt: Date;
  150. }
  151. export interface DeviceConfig {
  152. captureIntervalMinutes: number;
  153. resolution: string;
  154. quality: number;
  155. uploadOnWifiOnly: boolean;
  156. nightModeEnabled: boolean;
  157. nightModeStart: string;
  158. nightModeEnd: string;
  159. maxStorageGb: number;
  160. heartbeatIntervalSeconds: number;
  161. timezone: string;
  162. }
  163. export interface DeviceRegistrationInput {
  164. claimCode: string;
  165. serialNo: string;
  166. name: string;
  167. projectId: string;
  168. }
  169. export interface DeviceHeartbeatInput {
  170. deviceId: string;
  171. apiKey: string;
  172. status: DeviceStatus;
  173. tempC: number | null;
  174. batteryPct: number | null;
  175. storageFreeGb: number;
  176. capturesToday: number;
  177. lastCaptureAt: string | null;
  178. firmwareVersion: string;
  179. networkStatus: 'online' | 'offline' | 'degraded';
  180. }
  181. export interface DeviceCommandInput {
  182. deviceId: string;
  183. commandType: DeviceCommandType;
  184. payload?: Record<string, unknown>;
  185. scheduledAt?: string;
  186. }
  187. export interface Capture {
  188. id: string;
  189. projectId: string;
  190. deviceId: string;
  191. capturedAt: Date;
  192. uploadedAt: Date | null;
  193. fileKey: string | null;
  194. thumbnailKey: string | null;
  195. checksum: string | null;
  196. resolution: string;
  197. fileSizeBytes: number | null;
  198. exposureMs: number | null;
  199. iso: number | null;
  200. aperture: string | null;
  201. gpsLat: number | null;
  202. gpsLng: number | null;
  203. status: CaptureStatus;
  204. metadata: Record<string, unknown>;
  205. createdAt: Date;
  206. }
  207. export interface CaptureUploadInitResponse {
  208. captureId: string;
  209. uploadUrl: string;
  210. uploadMethod: 'PUT';
  211. uploadHeaders: Record<string, string>;
  212. expiresAt: string;
  213. }
  214. export interface CaptureCompleteInput {
  215. captureId: string;
  216. checksum: string;
  217. fileSizeBytes: number;
  218. metadata?: {
  219. exposureMs?: number;
  220. iso?: number;
  221. aperture?: string;
  222. gpsLat?: number;
  223. gpsLng?: number;
  224. };
  225. }
  226. export interface Video {
  227. id: string;
  228. projectId: string;
  229. periodStart: Date;
  230. periodEnd: Date;
  231. fps: number;
  232. resolution: string;
  233. fileKey: string | null;
  234. thumbnailKey: string | null;
  235. durationSec: number | null;
  236. status: VideoStatus;
  237. generatedAt: Date | null;
  238. fileSizeBytes: number | null;
  239. createdAt: Date;
  240. }
  241. export interface VideoGenerateInput {
  242. projectId: string;
  243. periodStart: string;
  244. periodEnd: string;
  245. fps?: number;
  246. resolution?: string;
  247. }
  248. export interface Alert {
  249. id: string;
  250. orgId: string;
  251. projectId: string | null;
  252. deviceId: string | null;
  253. type: AlertType;
  254. severity: AlertSeverity;
  255. message: string;
  256. data: Record<string, unknown>;
  257. state: 'open' | 'acknowledged' | 'resolved';
  258. openedAt: Date;
  259. acknowledgedAt: Date | null;
  260. acknowledgedBy: string | null;
  261. resolvedAt: Date | null;
  262. }
  263. export interface AlertRule {
  264. id: string;
  265. orgId: string;
  266. name: string;
  267. type: AlertType;
  268. condition: AlertCondition;
  269. cooldownMinutes: number;
  270. enabled: boolean;
  271. notifyEmail: boolean;
  272. notifySms: boolean;
  273. webhookUrl: string | null;
  274. }
  275. export interface AlertCondition {
  276. metric: string;
  277. operator: 'gt' | 'lt' | 'eq' | 'gte' | 'lte';
  278. value: number;
  279. windowMinutes?: number;
  280. }
  281. export interface Command {
  282. id: string;
  283. deviceId: string;
  284. commandType: DeviceCommandType;
  285. payload: Record<string, unknown> | null;
  286. queuedAt: Date;
  287. deliveredAt: Date | null;
  288. acknowledgedAt: Date | null;
  289. resultStatus: CommandResultStatus;
  290. resultData: Record<string, unknown> | null;
  291. }
  292. export interface ProjectAnalytics {
  293. projectId: string;
  294. totalCaptures: number;
  295. totalStorageBytes: number;
  296. avgCapturesPerDay: number;
  297. captureSuccessRate: number;
  298. uploadSuccessRate: number;
  299. activeDevices: number;
  300. offlineDevices: number;
  301. alertsOpen: number;
  302. periodStart: string;
  303. periodEnd: string;
  304. }
  305. export interface DeviceAnalytics {
  306. deviceId: string;
  307. totalCaptures: number;
  308. capturesToday: number;
  309. capturesThisWeek: number;
  310. avgUptimePercent: number;
  311. lastSeenAt: string | null;
  312. storageUsedGb: number;
  313. uploadQueueDepth: number;
  314. }
  315. export type WebSocketEvent = {
  316. event: 'device.status.changed';
  317. data: {
  318. deviceId: string;
  319. status: DeviceStatus;
  320. previousStatus: DeviceStatus;
  321. };
  322. } | {
  323. event: 'device.heartbeat';
  324. data: {
  325. deviceId: string;
  326. status: DeviceStatus;
  327. storageFreeGb: number;
  328. };
  329. } | {
  330. event: 'capture.upload.completed';
  331. data: {
  332. captureId: string;
  333. projectId: string;
  334. deviceId: string;
  335. };
  336. } | {
  337. event: 'video.generation.completed';
  338. data: {
  339. videoId: string;
  340. projectId: string;
  341. status: VideoStatus;
  342. };
  343. } | {
  344. event: 'alert.opened';
  345. data: {
  346. alertId: string;
  347. type: AlertType;
  348. severity: AlertSeverity;
  349. };
  350. } | {
  351. event: 'alert.resolved';
  352. data: {
  353. alertId: string;
  354. };
  355. };
  356. export interface PaginationInput {
  357. page?: number;
  358. limit?: number;
  359. cursor?: string;
  360. }
  361. export interface PaginatedResult<T> {
  362. data: T[];
  363. total: number;
  364. page: number;
  365. limit: number;
  366. hasNextPage: boolean;
  367. nextCursor: string | null;
  368. }
  369. export interface ApiResponse<T> {
  370. success: boolean;
  371. data?: T;
  372. error?: {
  373. code: string;
  374. message: string;
  375. details?: Record<string, unknown>;
  376. };
  377. }
  378. //# sourceMappingURL=index.d.ts.map