@contember/bindx 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 (234) hide show
  1. package/dist/adapter/ContemberAdapter.d.ts +40 -0
  2. package/dist/adapter/ContemberAdapter.d.ts.map +1 -0
  3. package/dist/adapter/MockAdapter.d.ts +81 -0
  4. package/dist/adapter/MockAdapter.d.ts.map +1 -0
  5. package/dist/adapter/MockQueryEngine.d.ts +43 -0
  6. package/dist/adapter/MockQueryEngine.d.ts.map +1 -0
  7. package/dist/adapter/index.d.ts +5 -0
  8. package/dist/adapter/index.d.ts.map +1 -0
  9. package/dist/adapter/types.d.ts +184 -0
  10. package/dist/adapter/types.d.ts.map +1 -0
  11. package/dist/brand/ComponentBrand.d.ts +25 -0
  12. package/dist/brand/ComponentBrand.d.ts.map +1 -0
  13. package/dist/contember/index.d.ts +10 -0
  14. package/dist/contember/index.d.ts.map +1 -0
  15. package/dist/core/ActionDispatcher.d.ts +64 -0
  16. package/dist/core/ActionDispatcher.d.ts.map +1 -0
  17. package/dist/core/Disposable.d.ts +57 -0
  18. package/dist/core/Disposable.d.ts.map +1 -0
  19. package/dist/core/EntityLoader.d.ts +80 -0
  20. package/dist/core/EntityLoader.d.ts.map +1 -0
  21. package/dist/core/PersistenceManager.d.ts +126 -0
  22. package/dist/core/PersistenceManager.d.ts.map +1 -0
  23. package/dist/core/SelectionResolver.d.ts +21 -0
  24. package/dist/core/SelectionResolver.d.ts.map +1 -0
  25. package/dist/core/actionClassification.d.ts +48 -0
  26. package/dist/core/actionClassification.d.ts.map +1 -0
  27. package/dist/core/actions.d.ts +301 -0
  28. package/dist/core/actions.d.ts.map +1 -0
  29. package/dist/core/index.d.ts +4 -0
  30. package/dist/core/index.d.ts.map +1 -0
  31. package/dist/dataview/filterHandlers.d.ts +18 -0
  32. package/dist/dataview/filterHandlers.d.ts.map +1 -0
  33. package/dist/dataview/index.d.ts +3 -0
  34. package/dist/dataview/index.d.ts.map +1 -0
  35. package/dist/dataview/types.d.ts +164 -0
  36. package/dist/dataview/types.d.ts.map +1 -0
  37. package/dist/errors/UnfetchedFieldError.d.ts +11 -0
  38. package/dist/errors/UnfetchedFieldError.d.ts.map +1 -0
  39. package/dist/errors/errorPathResolver.d.ts +52 -0
  40. package/dist/errors/errorPathResolver.d.ts.map +1 -0
  41. package/dist/errors/index.d.ts +5 -0
  42. package/dist/errors/index.d.ts.map +1 -0
  43. package/dist/errors/pathMapper.d.ts +42 -0
  44. package/dist/errors/pathMapper.d.ts.map +1 -0
  45. package/dist/errors/types.d.ts +131 -0
  46. package/dist/errors/types.d.ts.map +1 -0
  47. package/dist/events/EventEmitter.d.ts +97 -0
  48. package/dist/events/EventEmitter.d.ts.map +1 -0
  49. package/dist/events/eventFactory.d.ts +40 -0
  50. package/dist/events/eventFactory.d.ts.map +1 -0
  51. package/dist/events/index.d.ts +15 -0
  52. package/dist/events/index.d.ts.map +1 -0
  53. package/dist/events/types.d.ts +264 -0
  54. package/dist/events/types.d.ts.map +1 -0
  55. package/dist/handles/BaseHandle.d.ts +64 -0
  56. package/dist/handles/BaseHandle.d.ts.map +1 -0
  57. package/dist/handles/EntityHandle.d.ts +208 -0
  58. package/dist/handles/EntityHandle.d.ts.map +1 -0
  59. package/dist/handles/FieldHandle.d.ts +111 -0
  60. package/dist/handles/FieldHandle.d.ts.map +1 -0
  61. package/dist/handles/HasManyListHandle.d.ts +166 -0
  62. package/dist/handles/HasManyListHandle.d.ts.map +1 -0
  63. package/dist/handles/HasOneHandle.d.ts +168 -0
  64. package/dist/handles/HasOneHandle.d.ts.map +1 -0
  65. package/dist/handles/PlaceholderHandle.d.ts +117 -0
  66. package/dist/handles/PlaceholderHandle.d.ts.map +1 -0
  67. package/dist/handles/index.d.ts +8 -0
  68. package/dist/handles/index.d.ts.map +1 -0
  69. package/dist/handles/proxyFactory.d.ts +66 -0
  70. package/dist/handles/proxyFactory.d.ts.map +1 -0
  71. package/dist/handles/types.d.ts +430 -0
  72. package/dist/handles/types.d.ts.map +1 -0
  73. package/dist/index.d.ts +53 -0
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/internal.d.ts +11 -0
  76. package/dist/internal.d.ts.map +1 -0
  77. package/dist/persistence/BatchPersister.d.ts +142 -0
  78. package/dist/persistence/BatchPersister.d.ts.map +1 -0
  79. package/dist/persistence/ChangeRegistry.d.ts +87 -0
  80. package/dist/persistence/ChangeRegistry.d.ts.map +1 -0
  81. package/dist/persistence/ContemberSchemaMutationAdapter.d.ts +16 -0
  82. package/dist/persistence/ContemberSchemaMutationAdapter.d.ts.map +1 -0
  83. package/dist/persistence/MutationCollector.d.ts +96 -0
  84. package/dist/persistence/MutationCollector.d.ts.map +1 -0
  85. package/dist/persistence/MutationSchemaProvider.d.ts +30 -0
  86. package/dist/persistence/MutationSchemaProvider.d.ts.map +1 -0
  87. package/dist/persistence/index.d.ts +7 -0
  88. package/dist/persistence/index.d.ts.map +1 -0
  89. package/dist/persistence/types.d.ts +189 -0
  90. package/dist/persistence/types.d.ts.map +1 -0
  91. package/dist/roles/RoleSchemaRegistry.d.ts +77 -0
  92. package/dist/roles/RoleSchemaRegistry.d.ts.map +1 -0
  93. package/dist/roles/index.d.ts +11 -0
  94. package/dist/roles/index.d.ts.map +1 -0
  95. package/dist/roles/types.d.ts +242 -0
  96. package/dist/roles/types.d.ts.map +1 -0
  97. package/dist/schema/ContemberSchema.d.ts +98 -0
  98. package/dist/schema/ContemberSchema.d.ts.map +1 -0
  99. package/dist/schema/SchemaLoader.d.ts +28 -0
  100. package/dist/schema/SchemaLoader.d.ts.map +1 -0
  101. package/dist/schema/SchemaRegistry.d.ts +95 -0
  102. package/dist/schema/SchemaRegistry.d.ts.map +1 -0
  103. package/dist/schema/index.d.ts +6 -0
  104. package/dist/schema/index.d.ts.map +1 -0
  105. package/dist/schema/roles.d.ts +62 -0
  106. package/dist/schema/roles.d.ts.map +1 -0
  107. package/dist/schema/types.d.ts +179 -0
  108. package/dist/schema/types.d.ts.map +1 -0
  109. package/dist/selection/SelectionMetaCollector.d.ts +32 -0
  110. package/dist/selection/SelectionMetaCollector.d.ts.map +1 -0
  111. package/dist/selection/SelectionScope.d.ts +77 -0
  112. package/dist/selection/SelectionScope.d.ts.map +1 -0
  113. package/dist/selection/buildQuery.d.ts +45 -0
  114. package/dist/selection/buildQuery.d.ts.map +1 -0
  115. package/dist/selection/createFragment.d.ts +29 -0
  116. package/dist/selection/createFragment.d.ts.map +1 -0
  117. package/dist/selection/createSelectionBuilder.d.ts +18 -0
  118. package/dist/selection/createSelectionBuilder.d.ts.map +1 -0
  119. package/dist/selection/index.d.ts +8 -0
  120. package/dist/selection/index.d.ts.map +1 -0
  121. package/dist/selection/queryTypes.d.ts +84 -0
  122. package/dist/selection/queryTypes.d.ts.map +1 -0
  123. package/dist/selection/types.d.ts +238 -0
  124. package/dist/selection/types.d.ts.map +1 -0
  125. package/dist/store/DirtyTracker.d.ts +26 -0
  126. package/dist/store/DirtyTracker.d.ts.map +1 -0
  127. package/dist/store/EntityMetaStore.d.ts +52 -0
  128. package/dist/store/EntityMetaStore.d.ts.map +1 -0
  129. package/dist/store/EntitySnapshotStore.d.ts +63 -0
  130. package/dist/store/EntitySnapshotStore.d.ts.map +1 -0
  131. package/dist/store/ErrorStore.d.ts +82 -0
  132. package/dist/store/ErrorStore.d.ts.map +1 -0
  133. package/dist/store/RelationStore.d.ts +175 -0
  134. package/dist/store/RelationStore.d.ts.map +1 -0
  135. package/dist/store/SnapshotStore.d.ts +143 -0
  136. package/dist/store/SnapshotStore.d.ts.map +1 -0
  137. package/dist/store/SubscriptionManager.d.ts +90 -0
  138. package/dist/store/SubscriptionManager.d.ts.map +1 -0
  139. package/dist/store/TouchedStore.d.ts +24 -0
  140. package/dist/store/TouchedStore.d.ts.map +1 -0
  141. package/dist/store/entityId.d.ts +29 -0
  142. package/dist/store/entityId.d.ts.map +1 -0
  143. package/dist/store/index.d.ts +1 -0
  144. package/dist/store/index.d.ts.map +1 -0
  145. package/dist/store/snapshots.d.ts +144 -0
  146. package/dist/store/snapshots.d.ts.map +1 -0
  147. package/dist/undo/UndoManager.d.ts +120 -0
  148. package/dist/undo/UndoManager.d.ts.map +1 -0
  149. package/dist/undo/index.d.ts +3 -0
  150. package/dist/undo/index.d.ts.map +1 -0
  151. package/dist/undo/types.d.ts +74 -0
  152. package/dist/undo/types.d.ts.map +1 -0
  153. package/dist/utils/aliasGenerator.d.ts +25 -0
  154. package/dist/utils/aliasGenerator.d.ts.map +1 -0
  155. package/dist/utils/deepEqual.d.ts +6 -0
  156. package/dist/utils/deepEqual.d.ts.map +1 -0
  157. package/dist/utils/index.d.ts +3 -0
  158. package/dist/utils/index.d.ts.map +1 -0
  159. package/package.json +29 -0
  160. package/src/adapter/ContemberAdapter.ts +239 -0
  161. package/src/adapter/MockAdapter.ts +394 -0
  162. package/src/adapter/MockQueryEngine.ts +236 -0
  163. package/src/adapter/index.ts +21 -0
  164. package/src/adapter/types.ts +199 -0
  165. package/src/brand/ComponentBrand.ts +28 -0
  166. package/src/contember/index.ts +17 -0
  167. package/src/core/ActionDispatcher.ts +450 -0
  168. package/src/core/Disposable.ts +126 -0
  169. package/src/core/EntityLoader.ts +169 -0
  170. package/src/core/SelectionResolver.ts +78 -0
  171. package/src/core/actionClassification.ts +196 -0
  172. package/src/core/actions.ts +491 -0
  173. package/src/core/index.ts +20 -0
  174. package/src/dataview/filterHandlers.ts +443 -0
  175. package/src/dataview/index.ts +36 -0
  176. package/src/dataview/types.ts +220 -0
  177. package/src/errors/UnfetchedFieldError.ts +18 -0
  178. package/src/errors/errorPathResolver.ts +239 -0
  179. package/src/errors/index.ts +40 -0
  180. package/src/errors/pathMapper.ts +40 -0
  181. package/src/errors/types.ts +223 -0
  182. package/src/events/EventEmitter.ts +447 -0
  183. package/src/events/eventFactory.ts +430 -0
  184. package/src/events/index.ts +89 -0
  185. package/src/events/types.ts +374 -0
  186. package/src/handles/BaseHandle.ts +100 -0
  187. package/src/handles/EntityHandle.ts +538 -0
  188. package/src/handles/FieldHandle.ts +268 -0
  189. package/src/handles/HasManyListHandle.ts +500 -0
  190. package/src/handles/HasOneHandle.ts +500 -0
  191. package/src/handles/PlaceholderHandle.ts +321 -0
  192. package/src/handles/index.ts +37 -0
  193. package/src/handles/proxyFactory.ts +218 -0
  194. package/src/handles/types.ts +743 -0
  195. package/src/index.ts +384 -0
  196. package/src/internal.ts +19 -0
  197. package/src/persistence/BatchPersister.ts +911 -0
  198. package/src/persistence/ChangeRegistry.ts +150 -0
  199. package/src/persistence/ContemberSchemaMutationAdapter.ts +57 -0
  200. package/src/persistence/MutationCollector.ts +567 -0
  201. package/src/persistence/MutationSchemaProvider.ts +33 -0
  202. package/src/persistence/index.ts +23 -0
  203. package/src/persistence/types.ts +220 -0
  204. package/src/schema/ContemberSchema.ts +132 -0
  205. package/src/schema/SchemaLoader.ts +93 -0
  206. package/src/schema/SchemaRegistry.ts +286 -0
  207. package/src/schema/index.ts +51 -0
  208. package/src/schema/roles.ts +83 -0
  209. package/src/schema/types.ts +238 -0
  210. package/src/selection/SelectionMetaCollector.ts +122 -0
  211. package/src/selection/SelectionScope.ts +208 -0
  212. package/src/selection/buildQuery.ts +134 -0
  213. package/src/selection/createFragment.ts +50 -0
  214. package/src/selection/createSelectionBuilder.ts +283 -0
  215. package/src/selection/index.ts +31 -0
  216. package/src/selection/queryTypes.ts +135 -0
  217. package/src/selection/types.ts +320 -0
  218. package/src/store/DirtyTracker.ts +117 -0
  219. package/src/store/EntityMetaStore.ts +143 -0
  220. package/src/store/EntitySnapshotStore.ts +260 -0
  221. package/src/store/ErrorStore.ts +251 -0
  222. package/src/store/RelationStore.ts +696 -0
  223. package/src/store/SnapshotStore.ts +765 -0
  224. package/src/store/SubscriptionManager.ts +241 -0
  225. package/src/store/TouchedStore.ts +42 -0
  226. package/src/store/entityId.ts +43 -0
  227. package/src/store/index.ts +2 -0
  228. package/src/store/snapshots.ts +203 -0
  229. package/src/undo/UndoManager.ts +418 -0
  230. package/src/undo/index.ts +9 -0
  231. package/src/undo/types.ts +84 -0
  232. package/src/utils/aliasGenerator.ts +56 -0
  233. package/src/utils/deepEqual.ts +33 -0
  234. package/src/utils/index.ts +2 -0
@@ -0,0 +1,175 @@
1
+ import type { HasOneRelationState } from '../handles/types.js';
2
+ import type { EntitySnapshot } from './snapshots.js';
3
+ /**
4
+ * Removal type for has-many items
5
+ */
6
+ export type HasManyRemovalType = 'disconnect' | 'delete';
7
+ /**
8
+ * Has-many list state stored in SnapshotStore
9
+ */
10
+ export interface StoredHasManyState {
11
+ /** IDs of items from server */
12
+ serverIds: Set<string>;
13
+ /** Explicit ordered list of item IDs, null means use default order (serverIds + plannedConnections) */
14
+ orderedIds: string[] | null;
15
+ /** Planned removals (disconnect or delete) keyed by entity ID */
16
+ plannedRemovals: Map<string, HasManyRemovalType>;
17
+ /** Planned connections (IDs to add to the list) */
18
+ plannedConnections: Set<string>;
19
+ /** Entity IDs created via add() - tracked for proper remove() semantics and mutation generation */
20
+ createdEntities: Set<string>;
21
+ version: number;
22
+ }
23
+ /**
24
+ * Relation state stored in SnapshotStore
25
+ */
26
+ export interface StoredRelationState {
27
+ currentId: string | null;
28
+ serverId: string | null;
29
+ state: HasOneRelationState;
30
+ serverState: HasOneRelationState;
31
+ placeholderData: Record<string, unknown>;
32
+ version: number;
33
+ }
34
+ /**
35
+ * Manages has-one and has-many relation state.
36
+ *
37
+ * Relation keys use the format "parentType:parentId:fieldName".
38
+ * Notification is handled by callers via callback returns.
39
+ */
40
+ export declare class RelationStore {
41
+ /** Relation states keyed by "parentType:parentId:fieldName" */
42
+ private readonly relationStates;
43
+ /** Has-many list states keyed by "parentType:parentId:fieldName" */
44
+ private readonly hasManyStates;
45
+ /**
46
+ * Gets or creates relation state.
47
+ */
48
+ getOrCreateRelation(key: string, initial: Omit<StoredRelationState, 'version'>): StoredRelationState;
49
+ /**
50
+ * Gets relation state.
51
+ */
52
+ getRelation(key: string): StoredRelationState | undefined;
53
+ /**
54
+ * Updates relation state.
55
+ * If the relation state doesn't exist, creates it using entity snapshot for server data.
56
+ */
57
+ setRelation(key: string, updates: Partial<Omit<StoredRelationState, 'version'>>, entitySnapshot: EntitySnapshot | undefined, fieldName: string): void;
58
+ /**
59
+ * Commits relation state (server = current).
60
+ */
61
+ commitRelation(key: string): void;
62
+ /**
63
+ * Resets relation to server state.
64
+ */
65
+ resetRelation(key: string): void;
66
+ /**
67
+ * Gets or creates has-many list state.
68
+ */
69
+ getOrCreateHasMany(key: string, serverIds?: string[]): StoredHasManyState;
70
+ /**
71
+ * Gets has-many list state.
72
+ */
73
+ getHasMany(key: string): StoredHasManyState | undefined;
74
+ /**
75
+ * Sets server IDs for a has-many relation.
76
+ */
77
+ setHasManyServerIds(key: string, serverIds: string[]): void;
78
+ /**
79
+ * Plans a removal for a has-many item.
80
+ */
81
+ planHasManyRemoval(key: string, itemId: string, type: HasManyRemovalType): void;
82
+ /**
83
+ * Cancels a planned removal for a has-many item.
84
+ */
85
+ cancelHasManyRemoval(key: string, itemId: string): void;
86
+ /**
87
+ * Plans a connection for a has-many item.
88
+ */
89
+ planHasManyConnection(key: string, itemId: string): void;
90
+ /**
91
+ * Cancels a planned connection for a has-many item.
92
+ */
93
+ cancelHasManyConnection(key: string, itemId: string): void;
94
+ /**
95
+ * Commits has-many state after successful persist.
96
+ */
97
+ commitHasMany(key: string, newServerIds: string[]): void;
98
+ /**
99
+ * Resets has-many state to server state (clears planned operations).
100
+ */
101
+ resetHasMany(key: string): void;
102
+ /**
103
+ * Adds a newly created entity to a has-many relation.
104
+ * Used by HasManyListHandle.add() for inline entity creation.
105
+ */
106
+ addToHasMany(key: string, itemId: string): void;
107
+ /**
108
+ * Removes an entity from a has-many relation.
109
+ * For newly created entities (via add()), cancels the connection.
110
+ * For existing server entities, plans a disconnect.
111
+ * Returns the key if a removal was planned (caller should notify), or null if handled inline.
112
+ */
113
+ removeFromHasMany(key: string, itemId: string): 'planned_removal' | 'cancelled_connection' | null;
114
+ /**
115
+ * Moves an item within a has-many relation from one index to another.
116
+ */
117
+ moveInHasMany(key: string, fromIndex: number, toIndex: number): void;
118
+ /**
119
+ * Gets the ordered list of item IDs for a has-many relation.
120
+ */
121
+ getHasManyOrderedIds(key: string): string[];
122
+ /**
123
+ * Restores a has-many state from a captured snapshot.
124
+ * Used in pessimistic mode after successful server confirmation.
125
+ */
126
+ restoreHasManyState(key: string, state: StoredHasManyState): void;
127
+ /**
128
+ * Commits all relations (hasOne and hasMany) for an entity.
129
+ */
130
+ commitAllRelations(keyPrefix: string): void;
131
+ /**
132
+ * Resets all relations (hasOne and hasMany) for an entity to server state.
133
+ */
134
+ resetAllRelations(keyPrefix: string): void;
135
+ /**
136
+ * Gets all relation states for an entity.
137
+ */
138
+ getAllRelationsForEntity(keyPrefix: string): Map<string, StoredRelationState>;
139
+ /**
140
+ * Gets all has-many states for an entity.
141
+ */
142
+ getAllHasManyForEntity(keyPrefix: string): Map<string, StoredHasManyState>;
143
+ /**
144
+ * Gets the list of dirty relations for an entity.
145
+ */
146
+ getDirtyRelations(keyPrefix: string): string[];
147
+ /**
148
+ * Exports relation states for given keys.
149
+ */
150
+ exportRelationStates(keys: string[]): Map<string, StoredRelationState>;
151
+ /**
152
+ * Exports has-many states for given keys.
153
+ */
154
+ exportHasManyStates(keys: string[]): Map<string, StoredHasManyState>;
155
+ /**
156
+ * Imports relation states from a snapshot.
157
+ * Returns the keys that were imported for notification.
158
+ */
159
+ importRelationStates(states: Map<string, StoredRelationState>): string[];
160
+ /**
161
+ * Imports has-many states from a snapshot.
162
+ * Returns the keys that were imported for notification.
163
+ */
164
+ importHasManyStates(states: Map<string, StoredHasManyState>): string[];
165
+ /**
166
+ * Clears all relation data.
167
+ */
168
+ clear(): void;
169
+ }
170
+ /**
171
+ * Computes the default ordered IDs for a has-many relation.
172
+ * Order is: serverIds (minus removals) + plannedConnections
173
+ */
174
+ export declare function computeDefaultOrderedIds(state: StoredHasManyState): string[];
175
+ //# sourceMappingURL=RelationStore.d.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AAE,kBAAkB,CAAC,GAAG,MAAM,EAAE;IAgBtE;;OAEG;IACH,KAAK,IAAI,IAAI;CAIb;AAID;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAgB5E"}
@@ -0,0 +1,143 @@
1
+ import type { EntitySnapshot, LoadStatus } from './snapshots.js';
2
+ import type { FieldError } from '../errors/types.js';
3
+ import { type SnapshotVersionBumper } from './SubscriptionManager.js';
4
+ import { type HasManyRemovalType, type StoredHasManyState, type StoredRelationState } from './RelationStore.js';
5
+ import { type EntityMeta } from './EntityMetaStore.js';
6
+ export type { HasManyRemovalType, StoredHasManyState, StoredRelationState } from './RelationStore.js';
7
+ export type { EntityMeta } from './EntityMetaStore.js';
8
+ export { isTempId, isPlaceholderId, isPersistedId, generatePlaceholderId } from './entityId.js';
9
+ type Subscriber = () => void;
10
+ /**
11
+ * SnapshotStore manages immutable snapshots for React integration.
12
+ *
13
+ * Key design principles:
14
+ * - All data is stored as immutable, frozen objects
15
+ * - Changes create new snapshot instances (new references)
16
+ * - Provides subscribe/getSnapshot interface for useSyncExternalStore
17
+ * - Entity-level subscriptions for fine-grained reactivity
18
+ *
19
+ * Composed of:
20
+ * - EntitySnapshotStore — entity snapshot CRUD
21
+ * - SubscriptionManager — subscription tracking and notification
22
+ * - ErrorStore — field/entity/relation error tracking
23
+ * - RelationStore — has-one / has-many relation state management
24
+ * - EntityMetaStore — entity metadata, load state, persisting, temp ID mapping
25
+ * - TouchedStore — field touched state tracking
26
+ */
27
+ export declare class SnapshotStore implements SnapshotVersionBumper {
28
+ private readonly entitySnapshots;
29
+ private readonly subscriptions;
30
+ private readonly errors;
31
+ private readonly relations;
32
+ private readonly meta;
33
+ private readonly touched;
34
+ private readonly dirtyTracker;
35
+ constructor();
36
+ private getEntityKey;
37
+ private getRelationKey;
38
+ bumpEntitySnapshotVersion(key: string): void;
39
+ private notifyEntitySubscribers;
40
+ private notifyRelationSubscribers;
41
+ getEntitySnapshot<T extends object>(entityType: string, id: string): EntitySnapshot<T> | undefined;
42
+ hasEntity(entityType: string, id: string): boolean;
43
+ setEntityData<T extends object>(entityType: string, id: string, data: T, isServerData?: boolean, skipNotify?: boolean): EntitySnapshot<T>;
44
+ updateEntityFields<T extends object>(entityType: string, id: string, updates: Partial<T>): EntitySnapshot<T> | undefined;
45
+ setFieldValue(entityType: string, id: string, fieldPath: string[], value: unknown): void;
46
+ commitEntity(entityType: string, id: string): void;
47
+ resetEntity(entityType: string, id: string): void;
48
+ removeEntity(entityType: string, id: string): void;
49
+ getLoadState(entityType: string, id: string): {
50
+ status: LoadStatus;
51
+ error?: FieldError;
52
+ } | undefined;
53
+ setLoadState(entityType: string, id: string, status: LoadStatus, error?: FieldError): void;
54
+ getEntityMeta(entityType: string, id: string): EntityMeta | undefined;
55
+ setExistsOnServer(entityType: string, id: string, existsOnServer: boolean): void;
56
+ existsOnServer(entityType: string, id: string): boolean;
57
+ scheduleForDeletion(entityType: string, id: string): void;
58
+ unscheduleForDeletion(entityType: string, id: string): void;
59
+ isScheduledForDeletion(entityType: string, id: string): boolean;
60
+ createEntity(entityType: string, initialData?: Record<string, unknown>): string;
61
+ mapTempIdToPersistedId(entityType: string, tempId: string, persistedId: string): void;
62
+ getPersistedId(entityType: string, id: string): string | null;
63
+ isNewEntity(entityType: string, id: string): boolean;
64
+ getOrCreateHasMany(parentType: string, parentId: string, fieldName: string, serverIds?: string[], alias?: string): StoredHasManyState;
65
+ getHasMany(parentType: string, parentId: string, fieldName: string, alias?: string): StoredHasManyState | undefined;
66
+ setHasManyServerIds(parentType: string, parentId: string, fieldName: string, serverIds: string[], alias?: string): void;
67
+ planHasManyRemoval(parentType: string, parentId: string, fieldName: string, itemId: string, type: HasManyRemovalType, alias?: string): void;
68
+ cancelHasManyRemoval(parentType: string, parentId: string, fieldName: string, itemId: string, alias?: string): void;
69
+ getHasManyPlannedRemovals(parentType: string, parentId: string, fieldName: string, alias?: string): Map<string, HasManyRemovalType> | undefined;
70
+ planHasManyConnection(parentType: string, parentId: string, fieldName: string, itemId: string, alias?: string): void;
71
+ cancelHasManyConnection(parentType: string, parentId: string, fieldName: string, itemId: string, alias?: string): void;
72
+ getHasManyPlannedConnections(parentType: string, parentId: string, fieldName: string, alias?: string): Set<string> | undefined;
73
+ commitHasMany(parentType: string, parentId: string, fieldName: string, newServerIds: string[], alias?: string): void;
74
+ resetHasMany(parentType: string, parentId: string, fieldName: string, alias?: string): void;
75
+ addToHasMany(parentType: string, parentId: string, fieldName: string, itemId: string, alias?: string): void;
76
+ removeFromHasMany(parentType: string, parentId: string, fieldName: string, itemId: string, alias?: string): void;
77
+ moveInHasMany(parentType: string, parentId: string, fieldName: string, fromIndex: number, toIndex: number, alias?: string): void;
78
+ getHasManyOrderedIds(parentType: string, parentId: string, fieldName: string, alias?: string): string[];
79
+ isHasManyItemCreated(parentType: string, parentId: string, fieldName: string, itemId: string, alias?: string): boolean;
80
+ getHasManyCreatedEntities(parentType: string, parentId: string, fieldName: string, alias?: string): Set<string> | undefined;
81
+ isPersisting(entityType: string, id: string): boolean;
82
+ setPersisting(entityType: string, id: string, isPersisting: boolean): void;
83
+ getFieldErrors(entityType: string, id: string, fieldName: string): readonly FieldError[];
84
+ addFieldError(entityType: string, id: string, fieldName: string, error: FieldError): void;
85
+ clearFieldErrors(entityType: string, id: string, fieldName: string, source?: 'client' | 'server'): void;
86
+ clearNonStickyFieldErrors(entityType: string, id: string, fieldName: string): void;
87
+ getEntityErrors(entityType: string, id: string): readonly FieldError[];
88
+ addEntityError(entityType: string, id: string, error: FieldError): void;
89
+ clearEntityErrors(entityType: string, id: string, source?: 'client' | 'server'): void;
90
+ getRelationErrors(entityType: string, id: string, relationName: string): readonly FieldError[];
91
+ addRelationError(entityType: string, id: string, relationName: string, error: FieldError): void;
92
+ clearRelationErrors(entityType: string, id: string, relationName: string, source?: 'client' | 'server'): void;
93
+ clearAllServerErrors(entityType: string, id: string): void;
94
+ clearAllErrors(entityType: string, id: string): void;
95
+ hasClientErrors(entityType: string, id: string): boolean;
96
+ hasAnyErrors(entityType: string, id: string): boolean;
97
+ isFieldTouched(entityType: string, id: string, fieldName: string): boolean;
98
+ setFieldTouched(entityType: string, id: string, fieldName: string, touched: boolean): void;
99
+ clearEntityTouchedState(entityType: string, id: string): void;
100
+ getOrCreateRelation(parentType: string, parentId: string, fieldName: string, initial: Omit<StoredRelationState, 'version'>): StoredRelationState;
101
+ getRelation(parentType: string, parentId: string, fieldName: string): StoredRelationState | undefined;
102
+ setRelation(parentType: string, parentId: string, fieldName: string, updates: Partial<Omit<StoredRelationState, 'version'>>): void;
103
+ commitRelation(parentType: string, parentId: string, fieldName: string): void;
104
+ resetRelation(parentType: string, parentId: string, fieldName: string): void;
105
+ commitAllRelations(entityType: string, entityId: string): void;
106
+ resetAllRelations(entityType: string, entityId: string): void;
107
+ getAllRelationsForEntity(entityType: string, entityId: string): Map<string, StoredRelationState>;
108
+ getAllHasManyForEntity(entityType: string, entityId: string): Map<string, StoredHasManyState>;
109
+ restoreHasManyState(parentType: string, parentId: string, fieldName: string, state: StoredHasManyState, alias?: string): void;
110
+ subscribeToEntity(entityType: string, id: string, callback: Subscriber): () => void;
111
+ subscribeToRelation(parentType: string, parentId: string, fieldName: string, callback: Subscriber): () => void;
112
+ subscribe(callback: Subscriber): () => void;
113
+ getVersion(): number;
114
+ notify(): void;
115
+ registerParentChild(parentType: string, parentId: string, childType: string, childId: string): void;
116
+ unregisterParentChild(parentType: string, parentId: string, childType: string, childId: string): void;
117
+ exportPartialSnapshot(keys: {
118
+ entityKeys: string[];
119
+ relationKeys: string[];
120
+ hasManyKeys: string[];
121
+ }): {
122
+ entitySnapshots: Map<string, EntitySnapshot>;
123
+ relationStates: Map<string, StoredRelationState>;
124
+ hasManyStates: Map<string, StoredHasManyState>;
125
+ entityMetas: Map<string, EntityMeta>;
126
+ };
127
+ importPartialSnapshot(snapshot: {
128
+ entitySnapshots: Map<string, EntitySnapshot>;
129
+ relationStates: Map<string, StoredRelationState>;
130
+ hasManyStates: Map<string, StoredHasManyState>;
131
+ entityMetas: Map<string, EntityMeta>;
132
+ }): void;
133
+ getAllDirtyEntities(): Array<{
134
+ entityType: string;
135
+ entityId: string;
136
+ changeType: 'create' | 'update' | 'delete';
137
+ }>;
138
+ getDirtyFields(entityType: string, entityId: string): string[];
139
+ getDirtyRelations(entityType: string, entityId: string): string[];
140
+ commitFields(entityType: string, entityId: string, fieldNames: string[]): void;
141
+ clear(): void;
142
+ }
143
+ //# sourceMappingURL=SnapshotStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SnapshotStore.d.ts","sourceRoot":"","sources":["../../src/store/SnapshotStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAuB,KAAK,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAE1F,OAAO,EAEN,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAMvE,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACrG,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAE/F,KAAK,UAAU,GAAG,MAAM,IAAI,CAAA;AAE5B;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,aAAc,YAAW,qBAAqB;IAC1D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA4B;IAC5D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA4B;IAC1D,OAAO,CAAC,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,EAAE,MAAM,EAAE,GAAG,IAAI;IAQ9E,KAAK,IAAI,IAAI;CASb"}
@@ -0,0 +1,90 @@
1
+ type Subscriber = () => void;
2
+ /**
3
+ * Callback interface for SubscriptionManager to request snapshot version bumps.
4
+ * This decouples notification logic from entity snapshot storage.
5
+ */
6
+ export interface SnapshotVersionBumper {
7
+ bumpEntitySnapshotVersion(key: string): void;
8
+ }
9
+ /**
10
+ * Manages subscriptions for entity and relation changes.
11
+ *
12
+ * Provides:
13
+ * - Entity-level subscriptions
14
+ * - Relation-level subscriptions
15
+ * - Global subscriptions (any change)
16
+ * - Parent-child change propagation
17
+ * - Global version tracking for change detection
18
+ */
19
+ export declare class SubscriptionManager {
20
+ /** Subscribers per entity key */
21
+ private readonly entitySubscribers;
22
+ /** Subscribers per relation key */
23
+ private readonly relationSubscribers;
24
+ /** Global subscribers (notified on any change) */
25
+ private readonly globalSubscribers;
26
+ /** Parent-child relationships: childKey -> Set of parentKeys */
27
+ private readonly childToParents;
28
+ /** Global version number for change detection */
29
+ private globalVersion;
30
+ /**
31
+ * Subscribe to changes on a specific entity.
32
+ * Returns unsubscribe function.
33
+ */
34
+ subscribeToEntity(key: string, callback: Subscriber): () => void;
35
+ /**
36
+ * Subscribe to changes on a specific relation.
37
+ * Returns unsubscribe function.
38
+ */
39
+ subscribeToRelation(key: string, callback: Subscriber): () => void;
40
+ /**
41
+ * Subscribe to all changes (global).
42
+ * Returns unsubscribe function.
43
+ */
44
+ subscribe(callback: Subscriber): () => void;
45
+ /**
46
+ * Gets the global version number for change detection.
47
+ */
48
+ getVersion(): number;
49
+ /**
50
+ * Triggers a global notification to all subscribers.
51
+ * Use when external state changes need to trigger re-renders.
52
+ */
53
+ notify(): void;
54
+ /**
55
+ * Registers a parent-child relationship for change propagation.
56
+ * When the child entity changes, parent entity subscribers will be notified.
57
+ */
58
+ registerParentChild(parentKey: string, childKey: string): void;
59
+ /**
60
+ * Unregisters a parent-child relationship.
61
+ */
62
+ unregisterParentChild(parentKey: string, childKey: string): void;
63
+ /**
64
+ * Notifies entity subscribers and propagates changes to parents.
65
+ * The bumper callback is used to bump parent entity snapshot versions.
66
+ */
67
+ notifyEntitySubscribers(key: string, bumper: SnapshotVersionBumper, notifiedKeys?: Set<string>): void;
68
+ /**
69
+ * Notifies relation subscribers and the parent entity's subscribers.
70
+ * The bumper callback is used to bump the parent entity snapshot version.
71
+ * The entityKey is the parent entity key derived from the relation key.
72
+ */
73
+ notifyRelationSubscribers(key: string, entityKey: string, bumper: SnapshotVersionBumper): void;
74
+ /**
75
+ * Notifies entity subscribers without propagation.
76
+ * Used during batch imports (e.g., undo/redo).
77
+ */
78
+ notifyEntityDirect(key: string): void;
79
+ /**
80
+ * Notifies relation subscribers without propagation.
81
+ * Used during batch imports (e.g., undo/redo).
82
+ */
83
+ notifyRelationDirect(key: string): void;
84
+ /**
85
+ * Bumps global version and notifies global subscribers.
86
+ */
87
+ notifyGlobal(): void;
88
+ }
89
+ export {};
90
+ //# sourceMappingURL=SubscriptionManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubscriptionManager.d.ts","sourceRoot":"","sources":["../../src/store/SubscriptionManager.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GAAG,MAAM,IAAI,CAAA;AAE5B;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACrC,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5C;AAED;;;;;;;;;GASG;AACH,qBAAa,mBAAmB;IAC/B,iCAAiC;IACjC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAqC;IAEvE,mCAAmC;IACnC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAqC;IAEzE,kDAAkD;IAClD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAwB;IAE1D,gEAAgE;IAChE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiC;IAEhE,iDAAiD;IACjD,OAAO,CAAC,aAAa,CAAI;IAEzB;;;OAGG;IACH,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,MAAM,IAAI;IAYhE;;;OAGG;IACH,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,MAAM,IAAI;IAYlE;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM,IAAI;IAO3C;;OAEG;IACH,UAAU,IAAI,MAAM;IAIpB;;;OAGG;IACH,MAAM,IAAI,IAAI;IASd;;;OAGG;IACH,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAS9D;;OAEG;IACH,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAYhE;;;OAGG;IACH,uBAAuB,CACtB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,qBAAqB,EAC7B,YAAY,GAAE,GAAG,CAAC,MAAM,CAAa,GACnC,IAAI;IAiCP;;;;OAIG;IACH,yBAAyB,CACxB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,qBAAqB,GAC3B,IAAI;IA4BP;;;OAGG;IACH,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IASrC;;;OAGG;IACH,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IASvC;;OAEG;IACH,YAAY,IAAI,IAAI;CAMpB"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Manages touched state for entity fields.
3
+ *
4
+ * A field is "touched" when the user has interacted with it.
5
+ * Used for conditional error display (show errors only after user interaction).
6
+ *
7
+ * Keys are pre-computed composite strings (e.g., "entityType:id:fieldName").
8
+ */
9
+ export declare class TouchedStore {
10
+ /** Touched state keyed by "entityType:id:fieldName" */
11
+ private readonly touchedFields;
12
+ isFieldTouched(key: string): boolean;
13
+ /**
14
+ * Sets the touched state for a field.
15
+ * Returns true if the state actually changed.
16
+ */
17
+ setFieldTouched(key: string, touched: boolean): boolean;
18
+ /**
19
+ * Clears all touched state for an entity.
20
+ */
21
+ clearForEntity(keyPrefix: string): void;
22
+ clear(): void;
23
+ }
24
+ //# sourceMappingURL=TouchedStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TouchedStore.d.ts","sourceRoot":"","sources":["../../src/store/TouchedStore.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,YAAY;IACxB,uDAAuD;IACvD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA6B;IAE3D,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIpC;;;OAGG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO;IAOvD;;OAEG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAQvC,KAAK,IAAI,IAAI;CAGb"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Entity ID type detection and generation utilities.
3
+ *
4
+ * IDs in Bindx can be:
5
+ * - Persisted: server-assigned UUIDs
6
+ * - Temporary: locally created, prefixed with "__temp_"
7
+ * - Placeholder: disconnected relation placeholders, prefixed with "__placeholder_"
8
+ */
9
+ /**
10
+ * Checks if an ID is a temporary ID (created locally, not yet persisted).
11
+ */
12
+ export declare function isTempId(id: string): boolean;
13
+ /**
14
+ * Checks if an ID is a placeholder ID (disconnected relation placeholder).
15
+ */
16
+ export declare function isPlaceholderId(id: string): boolean;
17
+ /**
18
+ * Checks if an ID is a persisted/real ID from the server.
19
+ */
20
+ export declare function isPersistedId(id: string): boolean;
21
+ /**
22
+ * Generates a new placeholder ID.
23
+ */
24
+ export declare function generatePlaceholderId(): string;
25
+ /**
26
+ * Generates a new temporary ID.
27
+ */
28
+ export declare function generateTempId(): string;
29
+ //# sourceMappingURL=entityId.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entityId.d.ts","sourceRoot":"","sources":["../../src/store/entityId.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE5C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Immutable snapshot types for React integration.
3
+ * All snapshots are frozen objects that are replaced (not mutated) on changes.
4
+ */
5
+ import type { HasOneRelationState } from '../handles/types.js';
6
+ /**
7
+ * Status of a data load operation
8
+ */
9
+ export type LoadStatus = 'idle' | 'loading' | 'success' | 'error' | 'not_found';
10
+ /**
11
+ * Immutable snapshot of entity data stored in the IdentityMap.
12
+ * A new snapshot is created whenever the entity data changes.
13
+ */
14
+ export interface EntitySnapshot<T extends object = object> {
15
+ /** Entity ID */
16
+ readonly id: string;
17
+ /** Entity type name */
18
+ readonly entityType: string;
19
+ /** Current (local) data - may differ from serverData if modified */
20
+ readonly data: Readonly<T>;
21
+ /** Data as received from server - used for dirty tracking and reset */
22
+ readonly serverData: Readonly<T>;
23
+ /** Version number - incremented on each change, used for comparison */
24
+ readonly version: number;
25
+ }
26
+ /**
27
+ * Immutable snapshot of a scalar field value.
28
+ */
29
+ export interface FieldSnapshot<T = unknown> {
30
+ /** Current value */
31
+ readonly value: T | null;
32
+ /** Server value (for dirty tracking) */
33
+ readonly serverValue: T | null;
34
+ /** Whether the field has been modified */
35
+ readonly isDirty: boolean;
36
+ }
37
+ /**
38
+ * State information for a has-one relation.
39
+ */
40
+ export interface HasOneRelationSnapshot<T extends object = object> {
41
+ /** Current relation state */
42
+ readonly state: HasOneRelationState;
43
+ /** Current referenced entity ID (null if disconnected) */
44
+ readonly entityId: string | null;
45
+ /** Server-side entity ID (for dirty tracking) */
46
+ readonly serverEntityId: string | null;
47
+ /** The related entity snapshot (if connected and loaded) */
48
+ readonly entity: EntitySnapshot<T> | null;
49
+ /** Whether the relation has been modified */
50
+ readonly isDirty: boolean;
51
+ /** Version for change detection */
52
+ readonly version: number;
53
+ }
54
+ /**
55
+ * Item in a has-many relation list.
56
+ */
57
+ export interface HasManyItemSnapshot<T extends object = object> {
58
+ /** Unique key for React reconciliation */
59
+ readonly key: string;
60
+ /** The entity snapshot */
61
+ readonly entity: EntitySnapshot<T>;
62
+ /** Whether this item was added locally (not from server) */
63
+ readonly isNew: boolean;
64
+ }
65
+ /**
66
+ * Immutable snapshot of a has-many relation (entity list).
67
+ */
68
+ export interface HasManySnapshot<T extends object = object> {
69
+ /** List items in current order */
70
+ readonly items: ReadonlyArray<HasManyItemSnapshot<T>>;
71
+ /** Keys of items that came from the server */
72
+ readonly serverItemKeys: ReadonlySet<string>;
73
+ /** Keys of items that were added locally */
74
+ readonly addedKeys: ReadonlySet<string>;
75
+ /** Keys of items that were removed locally */
76
+ readonly removedKeys: ReadonlySet<string>;
77
+ /** Whether the order has been changed */
78
+ readonly orderChanged: boolean;
79
+ /** Whether the list has any modifications */
80
+ readonly isDirty: boolean;
81
+ /** Version for change detection */
82
+ readonly version: number;
83
+ }
84
+ /**
85
+ * Loading state for an entity.
86
+ */
87
+ export interface LoadingState {
88
+ readonly status: 'loading';
89
+ readonly id: string;
90
+ }
91
+ /**
92
+ * Error state for an entity.
93
+ */
94
+ export interface ErrorState {
95
+ readonly status: 'error';
96
+ readonly id: string;
97
+ readonly error: Error;
98
+ }
99
+ /**
100
+ * Not found state for an entity.
101
+ */
102
+ export interface NotFoundState {
103
+ readonly status: 'not_found';
104
+ readonly id: string;
105
+ }
106
+ /**
107
+ * Ready state with entity data.
108
+ */
109
+ export interface ReadyState<T extends object = object> {
110
+ readonly status: 'ready';
111
+ readonly id: string;
112
+ readonly entityType: string;
113
+ readonly snapshot: EntitySnapshot<T>;
114
+ }
115
+ /**
116
+ * Union of all possible entity states.
117
+ */
118
+ export type EntityState<T extends object = object> = LoadingState | ErrorState | NotFoundState | ReadyState<T>;
119
+ /**
120
+ * Helper to check if state is ready
121
+ */
122
+ export declare function isReadyState<T extends object>(state: EntityState<T>): state is ReadyState<T>;
123
+ /**
124
+ * Helper to check if state is loading
125
+ */
126
+ export declare function isLoadingState<T extends object>(state: EntityState<T>): state is LoadingState;
127
+ /**
128
+ * Helper to check if state is error
129
+ */
130
+ export declare function isErrorState<T extends object>(state: EntityState<T>): state is ErrorState;
131
+ /**
132
+ * Creates an immutable entity snapshot from data.
133
+ */
134
+ export declare function createEntitySnapshot<T extends object>(id: string, entityType: string, data: T, serverData: T, version: number): EntitySnapshot<T>;
135
+ /**
136
+ * Creates a new entity snapshot with updated data.
137
+ * Returns a new frozen object with incremented version.
138
+ */
139
+ export declare function updateEntitySnapshot<T extends object>(snapshot: EntitySnapshot<T>, updates: Partial<T>): EntitySnapshot<T>;
140
+ /**
141
+ * Creates a field snapshot from entity snapshot.
142
+ */
143
+ export declare function createFieldSnapshot<T>(value: T | null, serverValue: T | null): FieldSnapshot<T>;
144
+ //# sourceMappingURL=snapshots.d.ts.map