@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.
- package/dist/adapter/ContemberAdapter.d.ts +40 -0
- package/dist/adapter/ContemberAdapter.d.ts.map +1 -0
- package/dist/adapter/MockAdapter.d.ts +81 -0
- package/dist/adapter/MockAdapter.d.ts.map +1 -0
- package/dist/adapter/MockQueryEngine.d.ts +43 -0
- package/dist/adapter/MockQueryEngine.d.ts.map +1 -0
- package/dist/adapter/index.d.ts +5 -0
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/adapter/types.d.ts +184 -0
- package/dist/adapter/types.d.ts.map +1 -0
- package/dist/brand/ComponentBrand.d.ts +25 -0
- package/dist/brand/ComponentBrand.d.ts.map +1 -0
- package/dist/contember/index.d.ts +10 -0
- package/dist/contember/index.d.ts.map +1 -0
- package/dist/core/ActionDispatcher.d.ts +64 -0
- package/dist/core/ActionDispatcher.d.ts.map +1 -0
- package/dist/core/Disposable.d.ts +57 -0
- package/dist/core/Disposable.d.ts.map +1 -0
- package/dist/core/EntityLoader.d.ts +80 -0
- package/dist/core/EntityLoader.d.ts.map +1 -0
- package/dist/core/PersistenceManager.d.ts +126 -0
- package/dist/core/PersistenceManager.d.ts.map +1 -0
- package/dist/core/SelectionResolver.d.ts +21 -0
- package/dist/core/SelectionResolver.d.ts.map +1 -0
- package/dist/core/actionClassification.d.ts +48 -0
- package/dist/core/actionClassification.d.ts.map +1 -0
- package/dist/core/actions.d.ts +301 -0
- package/dist/core/actions.d.ts.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/dataview/filterHandlers.d.ts +18 -0
- package/dist/dataview/filterHandlers.d.ts.map +1 -0
- package/dist/dataview/index.d.ts +3 -0
- package/dist/dataview/index.d.ts.map +1 -0
- package/dist/dataview/types.d.ts +164 -0
- package/dist/dataview/types.d.ts.map +1 -0
- package/dist/errors/UnfetchedFieldError.d.ts +11 -0
- package/dist/errors/UnfetchedFieldError.d.ts.map +1 -0
- package/dist/errors/errorPathResolver.d.ts +52 -0
- package/dist/errors/errorPathResolver.d.ts.map +1 -0
- package/dist/errors/index.d.ts +5 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/pathMapper.d.ts +42 -0
- package/dist/errors/pathMapper.d.ts.map +1 -0
- package/dist/errors/types.d.ts +131 -0
- package/dist/errors/types.d.ts.map +1 -0
- package/dist/events/EventEmitter.d.ts +97 -0
- package/dist/events/EventEmitter.d.ts.map +1 -0
- package/dist/events/eventFactory.d.ts +40 -0
- package/dist/events/eventFactory.d.ts.map +1 -0
- package/dist/events/index.d.ts +15 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/types.d.ts +264 -0
- package/dist/events/types.d.ts.map +1 -0
- package/dist/handles/BaseHandle.d.ts +64 -0
- package/dist/handles/BaseHandle.d.ts.map +1 -0
- package/dist/handles/EntityHandle.d.ts +208 -0
- package/dist/handles/EntityHandle.d.ts.map +1 -0
- package/dist/handles/FieldHandle.d.ts +111 -0
- package/dist/handles/FieldHandle.d.ts.map +1 -0
- package/dist/handles/HasManyListHandle.d.ts +166 -0
- package/dist/handles/HasManyListHandle.d.ts.map +1 -0
- package/dist/handles/HasOneHandle.d.ts +168 -0
- package/dist/handles/HasOneHandle.d.ts.map +1 -0
- package/dist/handles/PlaceholderHandle.d.ts +117 -0
- package/dist/handles/PlaceholderHandle.d.ts.map +1 -0
- package/dist/handles/index.d.ts +8 -0
- package/dist/handles/index.d.ts.map +1 -0
- package/dist/handles/proxyFactory.d.ts +66 -0
- package/dist/handles/proxyFactory.d.ts.map +1 -0
- package/dist/handles/types.d.ts +430 -0
- package/dist/handles/types.d.ts.map +1 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/internal.d.ts +11 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/persistence/BatchPersister.d.ts +142 -0
- package/dist/persistence/BatchPersister.d.ts.map +1 -0
- package/dist/persistence/ChangeRegistry.d.ts +87 -0
- package/dist/persistence/ChangeRegistry.d.ts.map +1 -0
- package/dist/persistence/ContemberSchemaMutationAdapter.d.ts +16 -0
- package/dist/persistence/ContemberSchemaMutationAdapter.d.ts.map +1 -0
- package/dist/persistence/MutationCollector.d.ts +96 -0
- package/dist/persistence/MutationCollector.d.ts.map +1 -0
- package/dist/persistence/MutationSchemaProvider.d.ts +30 -0
- package/dist/persistence/MutationSchemaProvider.d.ts.map +1 -0
- package/dist/persistence/index.d.ts +7 -0
- package/dist/persistence/index.d.ts.map +1 -0
- package/dist/persistence/types.d.ts +189 -0
- package/dist/persistence/types.d.ts.map +1 -0
- package/dist/roles/RoleSchemaRegistry.d.ts +77 -0
- package/dist/roles/RoleSchemaRegistry.d.ts.map +1 -0
- package/dist/roles/index.d.ts +11 -0
- package/dist/roles/index.d.ts.map +1 -0
- package/dist/roles/types.d.ts +242 -0
- package/dist/roles/types.d.ts.map +1 -0
- package/dist/schema/ContemberSchema.d.ts +98 -0
- package/dist/schema/ContemberSchema.d.ts.map +1 -0
- package/dist/schema/SchemaLoader.d.ts +28 -0
- package/dist/schema/SchemaLoader.d.ts.map +1 -0
- package/dist/schema/SchemaRegistry.d.ts +95 -0
- package/dist/schema/SchemaRegistry.d.ts.map +1 -0
- package/dist/schema/index.d.ts +6 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/roles.d.ts +62 -0
- package/dist/schema/roles.d.ts.map +1 -0
- package/dist/schema/types.d.ts +179 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/selection/SelectionMetaCollector.d.ts +32 -0
- package/dist/selection/SelectionMetaCollector.d.ts.map +1 -0
- package/dist/selection/SelectionScope.d.ts +77 -0
- package/dist/selection/SelectionScope.d.ts.map +1 -0
- package/dist/selection/buildQuery.d.ts +45 -0
- package/dist/selection/buildQuery.d.ts.map +1 -0
- package/dist/selection/createFragment.d.ts +29 -0
- package/dist/selection/createFragment.d.ts.map +1 -0
- package/dist/selection/createSelectionBuilder.d.ts +18 -0
- package/dist/selection/createSelectionBuilder.d.ts.map +1 -0
- package/dist/selection/index.d.ts +8 -0
- package/dist/selection/index.d.ts.map +1 -0
- package/dist/selection/queryTypes.d.ts +84 -0
- package/dist/selection/queryTypes.d.ts.map +1 -0
- package/dist/selection/types.d.ts +238 -0
- package/dist/selection/types.d.ts.map +1 -0
- package/dist/store/DirtyTracker.d.ts +26 -0
- package/dist/store/DirtyTracker.d.ts.map +1 -0
- package/dist/store/EntityMetaStore.d.ts +52 -0
- package/dist/store/EntityMetaStore.d.ts.map +1 -0
- package/dist/store/EntitySnapshotStore.d.ts +63 -0
- package/dist/store/EntitySnapshotStore.d.ts.map +1 -0
- package/dist/store/ErrorStore.d.ts +82 -0
- package/dist/store/ErrorStore.d.ts.map +1 -0
- package/dist/store/RelationStore.d.ts +175 -0
- package/dist/store/RelationStore.d.ts.map +1 -0
- package/dist/store/SnapshotStore.d.ts +143 -0
- package/dist/store/SnapshotStore.d.ts.map +1 -0
- package/dist/store/SubscriptionManager.d.ts +90 -0
- package/dist/store/SubscriptionManager.d.ts.map +1 -0
- package/dist/store/TouchedStore.d.ts +24 -0
- package/dist/store/TouchedStore.d.ts.map +1 -0
- package/dist/store/entityId.d.ts +29 -0
- package/dist/store/entityId.d.ts.map +1 -0
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/snapshots.d.ts +144 -0
- package/dist/store/snapshots.d.ts.map +1 -0
- package/dist/undo/UndoManager.d.ts +120 -0
- package/dist/undo/UndoManager.d.ts.map +1 -0
- package/dist/undo/index.d.ts +3 -0
- package/dist/undo/index.d.ts.map +1 -0
- package/dist/undo/types.d.ts +74 -0
- package/dist/undo/types.d.ts.map +1 -0
- package/dist/utils/aliasGenerator.d.ts +25 -0
- package/dist/utils/aliasGenerator.d.ts.map +1 -0
- package/dist/utils/deepEqual.d.ts +6 -0
- package/dist/utils/deepEqual.d.ts.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/package.json +29 -0
- package/src/adapter/ContemberAdapter.ts +239 -0
- package/src/adapter/MockAdapter.ts +394 -0
- package/src/adapter/MockQueryEngine.ts +236 -0
- package/src/adapter/index.ts +21 -0
- package/src/adapter/types.ts +199 -0
- package/src/brand/ComponentBrand.ts +28 -0
- package/src/contember/index.ts +17 -0
- package/src/core/ActionDispatcher.ts +450 -0
- package/src/core/Disposable.ts +126 -0
- package/src/core/EntityLoader.ts +169 -0
- package/src/core/SelectionResolver.ts +78 -0
- package/src/core/actionClassification.ts +196 -0
- package/src/core/actions.ts +491 -0
- package/src/core/index.ts +20 -0
- package/src/dataview/filterHandlers.ts +443 -0
- package/src/dataview/index.ts +36 -0
- package/src/dataview/types.ts +220 -0
- package/src/errors/UnfetchedFieldError.ts +18 -0
- package/src/errors/errorPathResolver.ts +239 -0
- package/src/errors/index.ts +40 -0
- package/src/errors/pathMapper.ts +40 -0
- package/src/errors/types.ts +223 -0
- package/src/events/EventEmitter.ts +447 -0
- package/src/events/eventFactory.ts +430 -0
- package/src/events/index.ts +89 -0
- package/src/events/types.ts +374 -0
- package/src/handles/BaseHandle.ts +100 -0
- package/src/handles/EntityHandle.ts +538 -0
- package/src/handles/FieldHandle.ts +268 -0
- package/src/handles/HasManyListHandle.ts +500 -0
- package/src/handles/HasOneHandle.ts +500 -0
- package/src/handles/PlaceholderHandle.ts +321 -0
- package/src/handles/index.ts +37 -0
- package/src/handles/proxyFactory.ts +218 -0
- package/src/handles/types.ts +743 -0
- package/src/index.ts +384 -0
- package/src/internal.ts +19 -0
- package/src/persistence/BatchPersister.ts +911 -0
- package/src/persistence/ChangeRegistry.ts +150 -0
- package/src/persistence/ContemberSchemaMutationAdapter.ts +57 -0
- package/src/persistence/MutationCollector.ts +567 -0
- package/src/persistence/MutationSchemaProvider.ts +33 -0
- package/src/persistence/index.ts +23 -0
- package/src/persistence/types.ts +220 -0
- package/src/schema/ContemberSchema.ts +132 -0
- package/src/schema/SchemaLoader.ts +93 -0
- package/src/schema/SchemaRegistry.ts +286 -0
- package/src/schema/index.ts +51 -0
- package/src/schema/roles.ts +83 -0
- package/src/schema/types.ts +238 -0
- package/src/selection/SelectionMetaCollector.ts +122 -0
- package/src/selection/SelectionScope.ts +208 -0
- package/src/selection/buildQuery.ts +134 -0
- package/src/selection/createFragment.ts +50 -0
- package/src/selection/createSelectionBuilder.ts +283 -0
- package/src/selection/index.ts +31 -0
- package/src/selection/queryTypes.ts +135 -0
- package/src/selection/types.ts +320 -0
- package/src/store/DirtyTracker.ts +117 -0
- package/src/store/EntityMetaStore.ts +143 -0
- package/src/store/EntitySnapshotStore.ts +260 -0
- package/src/store/ErrorStore.ts +251 -0
- package/src/store/RelationStore.ts +696 -0
- package/src/store/SnapshotStore.ts +765 -0
- package/src/store/SubscriptionManager.ts +241 -0
- package/src/store/TouchedStore.ts +42 -0
- package/src/store/entityId.ts +43 -0
- package/src/store/index.ts +2 -0
- package/src/store/snapshots.ts +203 -0
- package/src/undo/UndoManager.ts +418 -0
- package/src/undo/index.ts +9 -0
- package/src/undo/types.ts +84 -0
- package/src/utils/aliasGenerator.ts +56 -0
- package/src/utils/deepEqual.ts +33 -0
- package/src/utils/index.ts +2 -0
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
import type { HasOneRelationState } from '../handles/types.js'
|
|
2
|
+
import type { FieldError } from '../errors/types.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Action types for the ActionDispatcher.
|
|
6
|
+
* All mutations to the store go through these actions.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// ==================== Field Actions ====================
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Sets a scalar field value
|
|
13
|
+
*/
|
|
14
|
+
export interface SetFieldAction {
|
|
15
|
+
readonly type: 'SET_FIELD'
|
|
16
|
+
readonly entityType: string
|
|
17
|
+
readonly entityId: string
|
|
18
|
+
readonly fieldPath: string[]
|
|
19
|
+
readonly value: unknown
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// ==================== Entity Actions ====================
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Resets an entity to its server data
|
|
26
|
+
*/
|
|
27
|
+
export interface ResetEntityAction {
|
|
28
|
+
readonly type: 'RESET_ENTITY'
|
|
29
|
+
readonly entityType: string
|
|
30
|
+
readonly entityId: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Commits entity changes (serverData = data)
|
|
35
|
+
*/
|
|
36
|
+
export interface CommitEntityAction {
|
|
37
|
+
readonly type: 'COMMIT_ENTITY'
|
|
38
|
+
readonly entityType: string
|
|
39
|
+
readonly entityId: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Sets entity data (usually from server)
|
|
44
|
+
*/
|
|
45
|
+
export interface SetEntityDataAction {
|
|
46
|
+
readonly type: 'SET_ENTITY_DATA'
|
|
47
|
+
readonly entityType: string
|
|
48
|
+
readonly entityId: string
|
|
49
|
+
readonly data: Record<string, unknown>
|
|
50
|
+
readonly isServerData: boolean
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ==================== Relation Actions ====================
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Connects a has-one relation to an entity
|
|
57
|
+
*/
|
|
58
|
+
export interface ConnectRelationAction {
|
|
59
|
+
readonly type: 'CONNECT_RELATION'
|
|
60
|
+
readonly entityType: string
|
|
61
|
+
readonly entityId: string
|
|
62
|
+
readonly fieldName: string
|
|
63
|
+
readonly targetId: string
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Disconnects a has-one relation
|
|
68
|
+
*/
|
|
69
|
+
export interface DisconnectRelationAction {
|
|
70
|
+
readonly type: 'DISCONNECT_RELATION'
|
|
71
|
+
readonly entityType: string
|
|
72
|
+
readonly entityId: string
|
|
73
|
+
readonly fieldName: string
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Marks a has-one relation for deletion
|
|
78
|
+
*/
|
|
79
|
+
export interface DeleteRelationAction {
|
|
80
|
+
readonly type: 'DELETE_RELATION'
|
|
81
|
+
readonly entityType: string
|
|
82
|
+
readonly entityId: string
|
|
83
|
+
readonly fieldName: string
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Resets a relation to server state
|
|
88
|
+
*/
|
|
89
|
+
export interface ResetRelationAction {
|
|
90
|
+
readonly type: 'RESET_RELATION'
|
|
91
|
+
readonly entityType: string
|
|
92
|
+
readonly entityId: string
|
|
93
|
+
readonly fieldName: string
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Commits relation changes
|
|
98
|
+
*/
|
|
99
|
+
export interface CommitRelationAction {
|
|
100
|
+
readonly type: 'COMMIT_RELATION'
|
|
101
|
+
readonly entityType: string
|
|
102
|
+
readonly entityId: string
|
|
103
|
+
readonly fieldName: string
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Sets placeholder data for a creating relation
|
|
108
|
+
*/
|
|
109
|
+
export interface SetPlaceholderDataAction {
|
|
110
|
+
readonly type: 'SET_PLACEHOLDER_DATA'
|
|
111
|
+
readonly entityType: string
|
|
112
|
+
readonly entityId: string
|
|
113
|
+
readonly fieldName: string
|
|
114
|
+
readonly fieldPath: string[]
|
|
115
|
+
readonly value: unknown
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// ==================== List Actions ====================
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Adds an item to a has-many list
|
|
122
|
+
*/
|
|
123
|
+
export interface AddToListAction {
|
|
124
|
+
readonly type: 'ADD_TO_LIST'
|
|
125
|
+
readonly entityType: string
|
|
126
|
+
readonly entityId: string
|
|
127
|
+
readonly fieldName: string
|
|
128
|
+
readonly targetType: string
|
|
129
|
+
readonly itemData?: Record<string, unknown>
|
|
130
|
+
readonly itemId?: string
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Removes an item from a has-many list
|
|
135
|
+
*/
|
|
136
|
+
export interface RemoveFromListAction {
|
|
137
|
+
readonly type: 'REMOVE_FROM_LIST'
|
|
138
|
+
readonly entityType: string
|
|
139
|
+
readonly entityId: string
|
|
140
|
+
readonly fieldName: string
|
|
141
|
+
readonly itemKey: string
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Moves an item within a has-many list
|
|
146
|
+
*/
|
|
147
|
+
export interface MoveInListAction {
|
|
148
|
+
readonly type: 'MOVE_IN_LIST'
|
|
149
|
+
readonly entityType: string
|
|
150
|
+
readonly entityId: string
|
|
151
|
+
readonly fieldName: string
|
|
152
|
+
readonly fromIndex: number
|
|
153
|
+
readonly toIndex: number
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// ==================== Load State Actions ====================
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Sets the load state for an entity
|
|
160
|
+
*/
|
|
161
|
+
export interface SetLoadStateAction {
|
|
162
|
+
readonly type: 'SET_LOAD_STATE'
|
|
163
|
+
readonly entityType: string
|
|
164
|
+
readonly entityId: string
|
|
165
|
+
readonly status: 'idle' | 'loading' | 'success' | 'error' | 'not_found'
|
|
166
|
+
readonly error?: FieldError
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Sets the persisting state for an entity
|
|
171
|
+
*/
|
|
172
|
+
export interface SetPersistingAction {
|
|
173
|
+
readonly type: 'SET_PERSISTING'
|
|
174
|
+
readonly entityType: string
|
|
175
|
+
readonly entityId: string
|
|
176
|
+
readonly isPersisting: boolean
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// ==================== Error Actions ====================
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Adds an error to a field
|
|
183
|
+
*/
|
|
184
|
+
export interface AddFieldErrorAction {
|
|
185
|
+
readonly type: 'ADD_FIELD_ERROR'
|
|
186
|
+
readonly entityType: string
|
|
187
|
+
readonly entityId: string
|
|
188
|
+
readonly fieldName: string
|
|
189
|
+
readonly error: FieldError
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Clears errors from a field
|
|
194
|
+
*/
|
|
195
|
+
export interface ClearFieldErrorsAction {
|
|
196
|
+
readonly type: 'CLEAR_FIELD_ERRORS'
|
|
197
|
+
readonly entityType: string
|
|
198
|
+
readonly entityId: string
|
|
199
|
+
readonly fieldName: string
|
|
200
|
+
readonly source?: 'client' | 'server'
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Adds an error to an entity
|
|
205
|
+
*/
|
|
206
|
+
export interface AddEntityErrorAction {
|
|
207
|
+
readonly type: 'ADD_ENTITY_ERROR'
|
|
208
|
+
readonly entityType: string
|
|
209
|
+
readonly entityId: string
|
|
210
|
+
readonly error: FieldError
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Clears errors from an entity
|
|
215
|
+
*/
|
|
216
|
+
export interface ClearEntityErrorsAction {
|
|
217
|
+
readonly type: 'CLEAR_ENTITY_ERRORS'
|
|
218
|
+
readonly entityType: string
|
|
219
|
+
readonly entityId: string
|
|
220
|
+
readonly source?: 'client' | 'server'
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Adds an error to a relation
|
|
225
|
+
*/
|
|
226
|
+
export interface AddRelationErrorAction {
|
|
227
|
+
readonly type: 'ADD_RELATION_ERROR'
|
|
228
|
+
readonly entityType: string
|
|
229
|
+
readonly entityId: string
|
|
230
|
+
readonly relationName: string
|
|
231
|
+
readonly error: FieldError
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Clears errors from a relation
|
|
236
|
+
*/
|
|
237
|
+
export interface ClearRelationErrorsAction {
|
|
238
|
+
readonly type: 'CLEAR_RELATION_ERRORS'
|
|
239
|
+
readonly entityType: string
|
|
240
|
+
readonly entityId: string
|
|
241
|
+
readonly relationName: string
|
|
242
|
+
readonly source?: 'client' | 'server'
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Clears all server errors for an entity (entity-level, fields, and relations)
|
|
247
|
+
*/
|
|
248
|
+
export interface ClearAllServerErrorsAction {
|
|
249
|
+
readonly type: 'CLEAR_ALL_SERVER_ERRORS'
|
|
250
|
+
readonly entityType: string
|
|
251
|
+
readonly entityId: string
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Clears all errors for an entity (entity-level, fields, and relations)
|
|
256
|
+
*/
|
|
257
|
+
export interface ClearAllErrorsAction {
|
|
258
|
+
readonly type: 'CLEAR_ALL_ERRORS'
|
|
259
|
+
readonly entityType: string
|
|
260
|
+
readonly entityId: string
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// ==================== Union Type ====================
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Union of all possible actions
|
|
267
|
+
*/
|
|
268
|
+
export type Action =
|
|
269
|
+
| SetFieldAction
|
|
270
|
+
| ResetEntityAction
|
|
271
|
+
| CommitEntityAction
|
|
272
|
+
| SetEntityDataAction
|
|
273
|
+
| ConnectRelationAction
|
|
274
|
+
| DisconnectRelationAction
|
|
275
|
+
| DeleteRelationAction
|
|
276
|
+
| ResetRelationAction
|
|
277
|
+
| CommitRelationAction
|
|
278
|
+
| SetPlaceholderDataAction
|
|
279
|
+
| AddToListAction
|
|
280
|
+
| RemoveFromListAction
|
|
281
|
+
| MoveInListAction
|
|
282
|
+
| SetLoadStateAction
|
|
283
|
+
| SetPersistingAction
|
|
284
|
+
| AddFieldErrorAction
|
|
285
|
+
| ClearFieldErrorsAction
|
|
286
|
+
| AddEntityErrorAction
|
|
287
|
+
| ClearEntityErrorsAction
|
|
288
|
+
| AddRelationErrorAction
|
|
289
|
+
| ClearRelationErrorsAction
|
|
290
|
+
| ClearAllServerErrorsAction
|
|
291
|
+
| ClearAllErrorsAction
|
|
292
|
+
|
|
293
|
+
// ==================== Action Creators ====================
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Creates a SET_FIELD action
|
|
297
|
+
*/
|
|
298
|
+
export function setField(
|
|
299
|
+
entityType: string,
|
|
300
|
+
entityId: string,
|
|
301
|
+
fieldPath: string[],
|
|
302
|
+
value: unknown,
|
|
303
|
+
): SetFieldAction {
|
|
304
|
+
return { type: 'SET_FIELD', entityType, entityId, fieldPath, value }
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Creates a RESET_ENTITY action
|
|
309
|
+
*/
|
|
310
|
+
export function resetEntity(entityType: string, entityId: string): ResetEntityAction {
|
|
311
|
+
return { type: 'RESET_ENTITY', entityType, entityId }
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Creates a COMMIT_ENTITY action
|
|
316
|
+
*/
|
|
317
|
+
export function commitEntity(entityType: string, entityId: string): CommitEntityAction {
|
|
318
|
+
return { type: 'COMMIT_ENTITY', entityType, entityId }
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Creates a SET_ENTITY_DATA action
|
|
323
|
+
*/
|
|
324
|
+
export function setEntityData(
|
|
325
|
+
entityType: string,
|
|
326
|
+
entityId: string,
|
|
327
|
+
data: Record<string, unknown>,
|
|
328
|
+
isServerData: boolean = false,
|
|
329
|
+
): SetEntityDataAction {
|
|
330
|
+
return { type: 'SET_ENTITY_DATA', entityType, entityId, data, isServerData }
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Creates a CONNECT_RELATION action
|
|
335
|
+
*/
|
|
336
|
+
export function connectRelation(
|
|
337
|
+
entityType: string,
|
|
338
|
+
entityId: string,
|
|
339
|
+
fieldName: string,
|
|
340
|
+
targetId: string,
|
|
341
|
+
): ConnectRelationAction {
|
|
342
|
+
return { type: 'CONNECT_RELATION', entityType, entityId, fieldName, targetId }
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Creates a DISCONNECT_RELATION action
|
|
347
|
+
*/
|
|
348
|
+
export function disconnectRelation(
|
|
349
|
+
entityType: string,
|
|
350
|
+
entityId: string,
|
|
351
|
+
fieldName: string,
|
|
352
|
+
): DisconnectRelationAction {
|
|
353
|
+
return { type: 'DISCONNECT_RELATION', entityType, entityId, fieldName }
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Creates a DELETE_RELATION action
|
|
358
|
+
*/
|
|
359
|
+
export function deleteRelation(
|
|
360
|
+
entityType: string,
|
|
361
|
+
entityId: string,
|
|
362
|
+
fieldName: string,
|
|
363
|
+
): DeleteRelationAction {
|
|
364
|
+
return { type: 'DELETE_RELATION', entityType, entityId, fieldName }
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Creates a SET_LOAD_STATE action
|
|
369
|
+
*/
|
|
370
|
+
export function setLoadState(
|
|
371
|
+
entityType: string,
|
|
372
|
+
entityId: string,
|
|
373
|
+
status: 'idle' | 'loading' | 'success' | 'error' | 'not_found',
|
|
374
|
+
error?: FieldError,
|
|
375
|
+
): SetLoadStateAction {
|
|
376
|
+
return { type: 'SET_LOAD_STATE', entityType, entityId, status, error }
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Creates a SET_PERSISTING action
|
|
381
|
+
*/
|
|
382
|
+
export function setPersisting(
|
|
383
|
+
entityType: string,
|
|
384
|
+
entityId: string,
|
|
385
|
+
isPersisting: boolean,
|
|
386
|
+
): SetPersistingAction {
|
|
387
|
+
return { type: 'SET_PERSISTING', entityType, entityId, isPersisting }
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Creates a SET_PLACEHOLDER_DATA action
|
|
392
|
+
*/
|
|
393
|
+
export function setPlaceholderData(
|
|
394
|
+
entityType: string,
|
|
395
|
+
entityId: string,
|
|
396
|
+
fieldName: string,
|
|
397
|
+
fieldPath: string[],
|
|
398
|
+
value: unknown,
|
|
399
|
+
): SetPlaceholderDataAction {
|
|
400
|
+
return { type: 'SET_PLACEHOLDER_DATA', entityType, entityId, fieldName, fieldPath, value }
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Creates an ADD_FIELD_ERROR action
|
|
405
|
+
*/
|
|
406
|
+
export function addFieldError(
|
|
407
|
+
entityType: string,
|
|
408
|
+
entityId: string,
|
|
409
|
+
fieldName: string,
|
|
410
|
+
error: FieldError,
|
|
411
|
+
): AddFieldErrorAction {
|
|
412
|
+
return { type: 'ADD_FIELD_ERROR', entityType, entityId, fieldName, error }
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Creates a CLEAR_FIELD_ERRORS action
|
|
417
|
+
*/
|
|
418
|
+
export function clearFieldErrors(
|
|
419
|
+
entityType: string,
|
|
420
|
+
entityId: string,
|
|
421
|
+
fieldName: string,
|
|
422
|
+
source?: 'client' | 'server',
|
|
423
|
+
): ClearFieldErrorsAction {
|
|
424
|
+
return { type: 'CLEAR_FIELD_ERRORS', entityType, entityId, fieldName, source }
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Creates an ADD_ENTITY_ERROR action
|
|
429
|
+
*/
|
|
430
|
+
export function addEntityError(
|
|
431
|
+
entityType: string,
|
|
432
|
+
entityId: string,
|
|
433
|
+
error: FieldError,
|
|
434
|
+
): AddEntityErrorAction {
|
|
435
|
+
return { type: 'ADD_ENTITY_ERROR', entityType, entityId, error }
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Creates a CLEAR_ENTITY_ERRORS action
|
|
440
|
+
*/
|
|
441
|
+
export function clearEntityErrors(
|
|
442
|
+
entityType: string,
|
|
443
|
+
entityId: string,
|
|
444
|
+
source?: 'client' | 'server',
|
|
445
|
+
): ClearEntityErrorsAction {
|
|
446
|
+
return { type: 'CLEAR_ENTITY_ERRORS', entityType, entityId, source }
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Creates an ADD_RELATION_ERROR action
|
|
451
|
+
*/
|
|
452
|
+
export function addRelationError(
|
|
453
|
+
entityType: string,
|
|
454
|
+
entityId: string,
|
|
455
|
+
relationName: string,
|
|
456
|
+
error: FieldError,
|
|
457
|
+
): AddRelationErrorAction {
|
|
458
|
+
return { type: 'ADD_RELATION_ERROR', entityType, entityId, relationName, error }
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Creates a CLEAR_RELATION_ERRORS action
|
|
463
|
+
*/
|
|
464
|
+
export function clearRelationErrors(
|
|
465
|
+
entityType: string,
|
|
466
|
+
entityId: string,
|
|
467
|
+
relationName: string,
|
|
468
|
+
source?: 'client' | 'server',
|
|
469
|
+
): ClearRelationErrorsAction {
|
|
470
|
+
return { type: 'CLEAR_RELATION_ERRORS', entityType, entityId, relationName, source }
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Creates a CLEAR_ALL_SERVER_ERRORS action
|
|
475
|
+
*/
|
|
476
|
+
export function clearAllServerErrors(
|
|
477
|
+
entityType: string,
|
|
478
|
+
entityId: string,
|
|
479
|
+
): ClearAllServerErrorsAction {
|
|
480
|
+
return { type: 'CLEAR_ALL_SERVER_ERRORS', entityType, entityId }
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Creates a CLEAR_ALL_ERRORS action
|
|
485
|
+
*/
|
|
486
|
+
export function clearAllErrors(
|
|
487
|
+
entityType: string,
|
|
488
|
+
entityId: string,
|
|
489
|
+
): ClearAllErrorsAction {
|
|
490
|
+
return { type: 'CLEAR_ALL_ERRORS', entityType, entityId }
|
|
491
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Entity Loading
|
|
2
|
+
export {
|
|
3
|
+
EntityLoader,
|
|
4
|
+
createEntityLoader,
|
|
5
|
+
type EntityLoadResult,
|
|
6
|
+
type EntityListLoadResult,
|
|
7
|
+
type LoadEntityOptions,
|
|
8
|
+
type LoadEntityListOptions,
|
|
9
|
+
} from './EntityLoader.js'
|
|
10
|
+
|
|
11
|
+
// Selection Resolution
|
|
12
|
+
export {
|
|
13
|
+
resolveSelectionMeta,
|
|
14
|
+
buildQuery,
|
|
15
|
+
type SelectionInput,
|
|
16
|
+
type FluentDefiner,
|
|
17
|
+
} from './SelectionResolver.js'
|
|
18
|
+
|
|
19
|
+
// Persistence
|
|
20
|
+
export type { MutationDataCollector } from '../persistence/types.js'
|