@glasshome/sync-layer 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +120 -0
  3. package/dist/area-views-B-m8vwce.js +321 -0
  4. package/dist/camera/fetch.d.ts +15 -0
  5. package/dist/camera/query.d.ts +15 -0
  6. package/dist/camera/types.d.ts +85 -0
  7. package/dist/camera/webrtc.d.ts +31 -0
  8. package/dist/commands/service.d.ts +53 -0
  9. package/dist/commands/types.d.ts +113 -0
  10. package/dist/connection/adapter.d.ts +48 -0
  11. package/dist/connection/auth.d.ts +126 -0
  12. package/dist/connection/manager.d.ts +42 -0
  13. package/dist/connection/subscriptions.d.ts +25 -0
  14. package/dist/connection/types.d.ts +161 -0
  15. package/dist/core/reducers.d.ts +99 -0
  16. package/dist/core/store.d.ts +64 -0
  17. package/dist/core/types.d.ts +336 -0
  18. package/dist/demo/demo-data.d.ts +24 -0
  19. package/dist/demo/demo-provider.d.ts +33 -0
  20. package/dist/demo/demo-provider.js +103 -0
  21. package/dist/demo-data-D8JXWRpw.js +419 -0
  22. package/dist/entities/area-views.d.ts +25 -0
  23. package/dist/entities/index.d.ts +54 -0
  24. package/dist/entities/views.d.ts +30 -0
  25. package/dist/history/constants.d.ts +16 -0
  26. package/dist/history/fetch.d.ts +19 -0
  27. package/dist/history/query.d.ts +13 -0
  28. package/dist/history/types.d.ts +146 -0
  29. package/dist/index.d.ts +38 -0
  30. package/dist/index.js +1747 -0
  31. package/dist/query/area-builder.d.ts +25 -0
  32. package/dist/query/builder.d.ts +18 -0
  33. package/dist/query/helpers.d.ts +21 -0
  34. package/dist/query/memoization.d.ts +18 -0
  35. package/dist/query/projections.d.ts +74 -0
  36. package/dist/query/types.d.ts +260 -0
  37. package/dist/solid/hooks.d.ts +88 -0
  38. package/dist/solid/index.d.ts +10 -0
  39. package/dist/solid/index.js +176 -0
  40. package/dist/solid/indices.d.ts +14 -0
  41. package/dist/store-B1sbyexX.js +54 -0
  42. package/dist/testing/fixtures.d.ts +161 -0
  43. package/dist/testing/helpers.d.ts +160 -0
  44. package/dist/testing/index.d.ts +13 -0
  45. package/dist/testing/index.js +2047 -0
  46. package/dist/testing/mock-behaviors/base.d.ts +73 -0
  47. package/dist/testing/mock-behaviors/climate.d.ts +22 -0
  48. package/dist/testing/mock-behaviors/cover.d.ts +22 -0
  49. package/dist/testing/mock-behaviors/index.d.ts +11 -0
  50. package/dist/testing/mock-behaviors/light.d.ts +20 -0
  51. package/dist/testing/mock-behaviors/lock.d.ts +20 -0
  52. package/dist/testing/mock-behaviors/media_player.d.ts +42 -0
  53. package/dist/testing/mock-behaviors/registry.d.ts +55 -0
  54. package/dist/testing/mock-behaviors/switch.d.ts +17 -0
  55. package/dist/testing/mock.d.ts +191 -0
  56. package/dist/testing/types.d.ts +87 -0
  57. package/dist/types-Csog0nqk.js +10 -0
  58. package/dist/weather/fetch.d.ts +19 -0
  59. package/dist/weather/query.d.ts +23 -0
  60. package/dist/weather/types.d.ts +126 -0
  61. package/package.json +85 -0
@@ -0,0 +1,146 @@
1
+ /**
2
+ * History Types
3
+ *
4
+ * Type definitions for entity history data.
5
+ * Based on Home Assistant frontend implementation.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import type { EntityId } from "../core/types";
10
+ /**
11
+ * History states record
12
+ * Maps entity IDs to their history state arrays
13
+ *
14
+ * Based on HA frontend: HistoryStates
15
+ */
16
+ export type HistoryStates = Record<string, EntityHistoryState[]>;
17
+ /**
18
+ * History stream message
19
+ * Used for history/stream subscription
20
+ *
21
+ * Based on HA frontend: HistoryStreamMessage
22
+ */
23
+ export interface HistoryStreamMessage {
24
+ /** History states */
25
+ states: HistoryStates;
26
+ /** Start time of this historical chunk (Unix timestamp in seconds) */
27
+ start_time?: number;
28
+ /** End time of this historical chunk (Unix timestamp in seconds) */
29
+ end_time?: number;
30
+ }
31
+ /**
32
+ * Entity history state point
33
+ * Represents a single point in entity history from Home Assistant
34
+ *
35
+ * Based on HA frontend: EntityHistoryState
36
+ */
37
+ export interface EntityHistoryState {
38
+ /** State value (compressed format from HA) */
39
+ s: string;
40
+ /** Attributes */
41
+ a: Record<string, any>;
42
+ /** Last changed timestamp (Unix timestamp in seconds, optional; if set, also applies to lu) */
43
+ lc?: number;
44
+ /** Last updated timestamp (Unix timestamp in seconds) */
45
+ lu: number;
46
+ }
47
+ /**
48
+ * Timeline state point
49
+ * Represents a point in the timeline with full data
50
+ */
51
+ export interface TimelineState {
52
+ /** Timestamp (Unix timestamp in seconds) */
53
+ timestamp: number;
54
+ /** State value */
55
+ state: string;
56
+ /** Attributes */
57
+ attributes?: Record<string, any>;
58
+ /** Last changed timestamp */
59
+ lastChanged?: number;
60
+ /** Last updated timestamp */
61
+ lastUpdated: number;
62
+ }
63
+ /**
64
+ * History data for a single entity
65
+ */
66
+ export interface EntityHistoryData {
67
+ /** Entity ID */
68
+ entityId: EntityId;
69
+ /** Timeline data points */
70
+ timeline: TimelineState[];
71
+ /** Compressed history states (from HA API) */
72
+ entityHistory: EntityHistoryState[];
73
+ /** Loading state */
74
+ loading: boolean;
75
+ /** Error if any */
76
+ error: Error | null;
77
+ /** Last fetched timestamp */
78
+ lastFetched: number | null;
79
+ }
80
+ /**
81
+ * History data for multiple entities
82
+ */
83
+ export interface HistoryData {
84
+ /** Entity ID -> History data */
85
+ [entityId: EntityId]: EntityHistoryData;
86
+ }
87
+ /**
88
+ * Options for history queries
89
+ *
90
+ * Based on HA frontend fetchDateWS parameters
91
+ */
92
+ export interface HistoryQueryOptions {
93
+ /** Start time (required) */
94
+ startTime: Date;
95
+ /** End time (optional, defaults to now) */
96
+ endTime?: Date;
97
+ /** Entity IDs to query (optional, defaults to all) */
98
+ entityIds?: EntityId[];
99
+ /** Include start time state */
100
+ includeStartTimeState?: boolean;
101
+ /** Only significant changes */
102
+ significantChangesOnly?: boolean;
103
+ /** Minimal response (defaults to true, matching HA frontend) */
104
+ minimalResponse?: boolean;
105
+ /** No attributes (if not provided, automatically determined based on entity domains) */
106
+ noAttributes?: boolean;
107
+ }
108
+ /**
109
+ * Single entity history query options
110
+ */
111
+ export interface EntityHistoryQueryOptions {
112
+ /** Start time (required) */
113
+ startTime: Date;
114
+ /** End time (optional, defaults to now) */
115
+ endTime?: Date;
116
+ /** Include start time state */
117
+ includeStartTimeState?: boolean;
118
+ /** Only significant changes */
119
+ significantChangesOnly?: boolean;
120
+ /** Minimal response (no attributes) */
121
+ minimalResponse?: boolean;
122
+ /** No attributes */
123
+ noAttributes?: boolean;
124
+ }
125
+ /**
126
+ * History query result
127
+ */
128
+ export interface HistoryResult {
129
+ /** History data for each entity */
130
+ data: HistoryData;
131
+ /** Loading state */
132
+ loading: boolean;
133
+ /** Error if any */
134
+ error: Error | null;
135
+ }
136
+ /**
137
+ * Single entity history result
138
+ */
139
+ export interface EntityHistoryResult {
140
+ /** History data */
141
+ data: EntityHistoryData | null;
142
+ /** Loading state */
143
+ loading: boolean;
144
+ /** Error if any */
145
+ error: Error | null;
146
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @glasshome/sync-layer
3
+ *
4
+ * Type-safe, reactive state synchronization layer for Home Assistant
5
+ * Uses SolidJS createStore for reactive state management.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export { addDebugIncomingMessageListener, addDebugOutgoingMessageListener, } from "./connection/adapter";
10
+ export type { ConnectionOptions } from "./connection/manager";
11
+ export { disconnect, getConnection, initConnection, isConnected } from "./connection/manager";
12
+ export type { SyncLayerConnection } from "./connection/types";
13
+ export type { OAuthOptions } from "./connection/auth";
14
+ export { authenticateWithOAuth, authenticateWithToken, isAuthValid, refreshAuth, } from "./connection/auth";
15
+ export { area, areas } from "./query/area-builder";
16
+ export { entities, entity } from "./query/builder";
17
+ export { entitiesByAreaAndDomain, entitiesWhere, searchEntities, } from "./query/helpers";
18
+ export type { AreaQueryBuilder, EntitiesQueryBuilder, EntityQueryBuilder, UnsubscribeFunc, } from "./query/types";
19
+ export { batchEntityUpdates, batchServiceCalls, callService, sendCommand, toggle, turnOff, turnOn, updateEntity, } from "./commands/service";
20
+ export type { CommandOptions, CommandResult, EntityUpdateFields, ServiceCallContext, ServiceTarget, } from "./commands/types";
21
+ export type { GlassHomeState } from "./core/store";
22
+ export type { AreaId, AreaView, DeviceId, DeviceView, EntityDomain, EntityId, EntityView, HassEntity, } from "./core/types";
23
+ export { resetStore, setState, state } from "./core/store";
24
+ export type { CallServiceRequest, CoreEventType, Domain, EntityCategory, EntityRegistryEntry, EventStateChangedData, HAEvent, RegistryEntryDisabler, RegistryEntryHider, ServiceCall, ServiceName, WsCommandType, WsResult, } from "@glasshome/ha-types";
25
+ export { fetchStream, fetchStreamData } from "./camera/fetch";
26
+ export { getStream, refreshStream } from "./camera/query";
27
+ export type { CameraStream, CameraStreamData, CameraStreams, EntityStreamQueryOptions, StreamFormat, StreamQueryOptions, StreamResult, } from "./camera/types";
28
+ export { getWebRtcClientConfig, sendWebRtcCandidate, startWebRtcSession, } from "./camera/webrtc";
29
+ export { buildAreaView, buildDeviceView, getAreaView, getAreaViews, } from "./entities/area-views";
30
+ export { buildEntityView, getAllEntityViews, getEntityView, getEntityViews, } from "./entities/views";
31
+ export { DOMAINS_USE_LAST_UPDATED, entityIdHistoryNeedsAttributes, LINE_ATTRIBUTES_TO_KEEP, NEED_ATTRIBUTE_DOMAINS, } from "./history/constants";
32
+ export { fetchEntityHistory, fetchHistory, historyStateToTimeline } from "./history/fetch";
33
+ export { appendHistoryPoint, isHistoryTracked, trackEntityHistory, untrackEntityHistory, } from "./history/query";
34
+ export type { EntityHistoryData, EntityHistoryQueryOptions, EntityHistoryResult, EntityHistoryState, HistoryData, HistoryQueryOptions, HistoryResult, HistoryStates, TimelineState, } from "./history/types";
35
+ export { fetchForecast, fetchForecastData, fetchForecasts } from "./weather/fetch";
36
+ export { getForecast, getForecasts, refreshForecast, refreshForecasts } from "./weather/query";
37
+ export type { EntityForecastQueryOptions, ForecastQueryOptions, ForecastResult, ForecastsResult, ForecastType, WeatherForecast, WeatherForecastData, WeatherForecasts, WeatherForecastsData, } from "./weather/types";
38
+ export declare const VERSION = "0.1.0";