@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,166 @@
1
+ import { EntityRelatedHandle } from './BaseHandle.js';
2
+ import type { ActionDispatcher } from '../core/ActionDispatcher.js';
3
+ import type { SnapshotStore } from '../store/SnapshotStore.js';
4
+ import type { SchemaRegistry } from '../schema/SchemaRegistry.js';
5
+ import type { SelectionMeta } from '../selection/types.js';
6
+ import { FIELD_REF_META, type HasManyRef, type FieldRefMeta, type EntityAccessor, type Unsubscribe } from './types.js';
7
+ import { type ErrorInput, type FieldError } from '../errors/types.js';
8
+ import type { EventListener, Interceptor, HasManyConnectedEvent, HasManyDisconnectedEvent, HasManyConnectingEvent, HasManyDisconnectingEvent } from '../events/types.js';
9
+ /**
10
+ * HasManyListHandle provides access to a has-many relation (list of entities).
11
+ * Implements HasManyRef interface for JSX compatibility.
12
+ *
13
+ * @typeParam TEntity - The full entity type of items in the relation
14
+ * @typeParam TSelected - The selected subset of fields (defaults to TEntity for backwards compatibility)
15
+ */
16
+ export declare class HasManyListHandle<TEntity extends object = object, TSelected = TEntity> extends EntityRelatedHandle implements HasManyRef<TEntity, TSelected> {
17
+ private readonly fieldName;
18
+ private readonly itemType;
19
+ private readonly schema;
20
+ private readonly selection?;
21
+ private itemHandleCache;
22
+ /** Runtime brand symbols for validation */
23
+ readonly __brands?: Set<symbol>;
24
+ /**
25
+ * Type brand - entity name for type inference.
26
+ * Implements HasManyRef.__entityName.
27
+ */
28
+ get __entityName(): string;
29
+ /**
30
+ * Type brand - schema for type inference.
31
+ * Returns undefined at runtime; schema type is compile-time only.
32
+ */
33
+ get __schema(): undefined;
34
+ /**
35
+ * Alias for this has-many relation.
36
+ * When the same field is used multiple times with different params,
37
+ * each instance has a unique alias to store data separately.
38
+ */
39
+ private readonly alias;
40
+ private constructor();
41
+ static create<TEntity extends object = object, TSelected = TEntity>(parentEntityType: string, parentEntityId: string, fieldName: string, itemType: string, store: SnapshotStore, dispatcher: ActionDispatcher, schema: SchemaRegistry, brands?: Set<symbol>, alias?: string, selection?: SelectionMeta): HasManyListHandle<TEntity, TSelected>;
42
+ /**
43
+ * JSX field reference metadata for collection phase.
44
+ * Implements HasManyRef interface.
45
+ */
46
+ get [FIELD_REF_META](): FieldRefMeta;
47
+ /**
48
+ * Gets the list of items as entity accessors with direct field access.
49
+ * Returns selection-aware EntityAccessors that support `item.fieldName.value`.
50
+ * Includes planned connections and excludes planned removals.
51
+ * Uses ordered IDs to preserve order including after move() operations.
52
+ */
53
+ get items(): EntityAccessor<TEntity, TSelected>[];
54
+ /**
55
+ * Ensures snapshots exist for embedded has-many items.
56
+ */
57
+ private ensureItemSnapshots;
58
+ /**
59
+ * Extracts items from either flat array or Connection format (paginateRelation).
60
+ * Returns null if data is not in a recognized format.
61
+ */
62
+ private extractItems;
63
+ /**
64
+ * Gets the total count from paginateRelation response.
65
+ * Content client attaches totalCount as a non-enumerable property on the array.
66
+ * Returns undefined if totalCount was not requested or not available.
67
+ */
68
+ get totalCount(): number | undefined;
69
+ /**
70
+ * Gets the number of items.
71
+ */
72
+ get length(): number;
73
+ /**
74
+ * Gets a handle for a specific item.
75
+ * Returns selection-aware EntityAccessor that supports direct field access.
76
+ */
77
+ getItemHandle(itemId: string): EntityAccessor<TEntity, TSelected>;
78
+ /**
79
+ * Gets an item handle by entity ID.
80
+ * Works for both server entities and newly created entities (via add()).
81
+ * Returns an EntityAccessor with direct field access.
82
+ */
83
+ getById(id: string): EntityAccessor<TEntity, TSelected>;
84
+ /**
85
+ * Checks if the list is dirty (items added/removed/moved/connected/disconnected).
86
+ */
87
+ get isDirty(): boolean;
88
+ /**
89
+ * Maps over items.
90
+ * Implements HasManyRef interface - returns selection-aware entity accessors with direct field access.
91
+ */
92
+ map<R>(fn: (item: EntityAccessor<TEntity, TSelected>, index: number) => R): R[];
93
+ /**
94
+ * Connects an existing entity to this has-many relation.
95
+ */
96
+ connect(itemId: string): void;
97
+ /**
98
+ * Disconnects an entity from this has-many relation.
99
+ */
100
+ disconnect(itemId: string): void;
101
+ /**
102
+ * Adds a new item to the list by creating a new entity.
103
+ * Returns the ID of the newly created entity (temp ID).
104
+ * For connecting existing entities, use connect() instead.
105
+ */
106
+ add(data?: Partial<TEntity>): string;
107
+ /**
108
+ * Removes an item from the list by ID.
109
+ * For newly created entities (via add()), cancels the add operation.
110
+ * For existing server entities, plans a disconnect.
111
+ */
112
+ remove(itemId: string): void;
113
+ /**
114
+ * Moves an item from one position to another within the list.
115
+ * Note: This only affects client-side order. For persistent ordering,
116
+ * use an 'order' field on the entity.
117
+ */
118
+ move(fromIndex: number, toIndex: number): void;
119
+ /**
120
+ * Resets the has-many relation to server state.
121
+ * Clears all planned connections and removals.
122
+ */
123
+ reset(): void;
124
+ /**
125
+ * Disposes the handle.
126
+ */
127
+ dispose(): void;
128
+ /**
129
+ * Type brand - ensures HasManyRef<Author> is not assignable to HasManyRef<Tag>.
130
+ * This is a phantom property that only exists in the type system.
131
+ */
132
+ get __entityType(): TEntity;
133
+ /**
134
+ * Gets the list of errors on this relation.
135
+ */
136
+ get errors(): readonly FieldError[];
137
+ /**
138
+ * Checks if this relation has any errors.
139
+ */
140
+ get hasError(): boolean;
141
+ /**
142
+ * Adds a client-side error to this relation.
143
+ */
144
+ addError(error: ErrorInput): void;
145
+ /**
146
+ * Clears all errors from this relation.
147
+ */
148
+ clearErrors(): void;
149
+ /**
150
+ * Subscribe to item connected events.
151
+ */
152
+ onItemConnected(listener: EventListener<HasManyConnectedEvent>): Unsubscribe;
153
+ /**
154
+ * Subscribe to item disconnected events.
155
+ */
156
+ onItemDisconnected(listener: EventListener<HasManyDisconnectedEvent>): Unsubscribe;
157
+ /**
158
+ * Intercept item connection (can cancel).
159
+ */
160
+ interceptItemConnecting(interceptor: Interceptor<HasManyConnectingEvent>): Unsubscribe;
161
+ /**
162
+ * Intercept item disconnection (can cancel).
163
+ */
164
+ interceptItemDisconnecting(interceptor: Interceptor<HasManyDisconnectingEvent>): Unsubscribe;
165
+ }
166
+ //# sourceMappingURL=HasManyListHandle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HasManyListHandle.d.ts","sourceRoot":"","sources":["../../src/handles/HasManyListHandle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAK1D,OAAO,EAAE,cAAc,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AACtH,OAAO,EAAqB,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACxF,OAAO,KAAK,EACX,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,EACzB,MAAM,oBAAoB,CAAA;AAG3B;;;;;;GAMG;AACH,qBAAa,iBAAiB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAAE,SAAS,GAAG,OAAO,CAAE,SAAQ,mBAAoB,YAAW,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC;IAgCxJ,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAGzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAGvB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;IAtC5B,OAAO,CAAC,eAAe,CAAsD;IAE7E,2CAA2C;IAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE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cher } from '../core/ActionDispatcher.js';
3
+ import type { SnapshotStore } from '../store/SnapshotStore.js';
4
+ import type { SchemaRegistry } from '../schema/SchemaRegistry.js';
5
+ import type { SelectionMeta } from '../selection/types.js';
6
+ import { FIELD_REF_META, type HasOneRef, type FieldRefMeta, type SelectedEntityFields, type Unsubscribe, type EntityAccessor } from './types.js';
7
+ import { type ErrorInput, type FieldError } from '../errors/types.js';
8
+ import type { EventTypeMap, AfterEventTypes, BeforeEventTypes, EventListener, Interceptor, EntityPersistedEvent, EntityPersistingEvent, RelationConnectedEvent, RelationDisconnectedEvent, RelationConnectingEvent, RelationDisconnectingEvent } from '../events/types.js';
9
+ /**
10
+ * HasOneHandle provides access to a has-one relation.
11
+ * Implements HasOneRef interface for JSX compatibility.
12
+ *
13
+ * @typeParam TEntity - The full entity type of the related entity
14
+ * @typeParam TSelected - The selected subset of fields (defaults to TEntity for backwards compatibility)
15
+ */
16
+ export declare class HasOneHandle<TEntity extends object = object, TSelected = TEntity> extends EntityRelatedHandle implements HasOneRef<TEntity, TSelected> {
17
+ private readonly fieldName;
18
+ private readonly targetType;
19
+ private readonly schema;
20
+ private readonly selection?;
21
+ private entityHandleCache;
22
+ private placeholderCache;
23
+ /** Runtime brand symbols for validation */
24
+ readonly __brands?: Set<symbol>;
25
+ /** Type brand for schema - placeholder at runtime */
26
+ readonly __schema: Record<string, object>;
27
+ readonly $id: string;
28
+ readonly $isDirty: boolean;
29
+ readonly $state: 'connected' | 'disconnected' | 'deleted' | 'creating';
30
+ readonly $fields: SelectedEntityFields<TEntity, TSelected>;
31
+ readonly $entity: EntityAccessor<TEntity, TSelected>;
32
+ readonly $errors: readonly FieldError[];
33
+ readonly $hasError: boolean;
34
+ $connect: (id: string) => void;
35
+ $disconnect: () => void;
36
+ $delete: () => void;
37
+ $reset: () => void;
38
+ $addError: (error: ErrorInput) => void;
39
+ $clearErrors: () => void;
40
+ $onConnect: (listener: EventListener<RelationConnectedEvent>) => Unsubscribe;
41
+ $onDisconnect: (listener: EventListener<RelationDisconnectedEvent>) => Unsubscribe;
42
+ $interceptConnect: (interceptor: Interceptor<RelationConnectingEvent>) => Unsubscribe;
43
+ $interceptDisconnect: (interceptor: Interceptor<RelationDisconnectingEvent>) => Unsubscribe;
44
+ private constructor();
45
+ static create<TEntity extends object = object, TSelected = TEntity>(parentEntityType: string, parentEntityId: string, fieldName: string, targetType: string, store: SnapshotStore, dispatcher: ActionDispatcher, schema: SchemaRegistry, brands?: Set<symbol>, selection?: SelectionMeta): HasOneHandle<TEntity, TSelected>;
46
+ /**
47
+ * JSX field reference metadata for collection phase.
48
+ * Implements HasOneRef interface.
49
+ */
50
+ get [FIELD_REF_META](): FieldRefMeta;
51
+ /**
52
+ * Subscribe to relation changes.
53
+ */
54
+ subscribe(callback: () => void): () => void;
55
+ /**
56
+ * Gets the relation state.
57
+ */
58
+ get state(): 'connected' | 'disconnected' | 'deleted' | 'creating';
59
+ /**
60
+ * Gets the current related entity ID.
61
+ * Falls back to entity data if relation state is not initialized.
62
+ */
63
+ get relatedId(): string | null;
64
+ /**
65
+ * Gets the related entity ID.
66
+ * Returns the actual ID if connected, or placeholder ID if disconnected.
67
+ * Implements HasOneRef interface.
68
+ */
69
+ get id(): string;
70
+ /**
71
+ * Gets the nested entity fields.
72
+ * Implements HasOneRef interface.
73
+ * Delegates to the entity (either real EntityHandle or PlaceholderHandle).
74
+ */
75
+ get fields(): SelectedEntityFields<TEntity, TSelected>;
76
+ /**
77
+ * Gets the related entity accessor with direct field access.
78
+ * Implements HasOneRef.$entity - returns EntityAccessor for the related entity.
79
+ * Returns PlaceholderHandle (with placeholder ID) if the relation is disconnected.
80
+ */
81
+ get entity(): EntityAccessor<TEntity, TSelected>;
82
+ /**
83
+ * Ensures the related entity has a snapshot in the store.
84
+ * If the related entity is embedded in the parent's data (not yet normalized),
85
+ * creates a snapshot from the embedded data.
86
+ */
87
+ private ensureRelatedEntitySnapshot;
88
+ /**
89
+ * Checks if the relation is dirty.
90
+ */
91
+ get isDirty(): boolean;
92
+ /**
93
+ * Connects the relation to an entity.
94
+ */
95
+ connect(targetId: string): void;
96
+ /**
97
+ * Disconnects the relation.
98
+ */
99
+ disconnect(): void;
100
+ /**
101
+ * Marks the relation for deletion.
102
+ */
103
+ delete(): void;
104
+ /**
105
+ * Resets the relation to server state.
106
+ */
107
+ reset(): void;
108
+ /**
109
+ * Disposes the handle.
110
+ */
111
+ dispose(): void;
112
+ /**
113
+ * Type brand - ensures HasOneRef<Author> is not assignable to HasOneRef<Tag>.
114
+ * This is a phantom property that only exists in the type system.
115
+ */
116
+ get __entityType(): TEntity;
117
+ /**
118
+ * Gets the list of errors on this relation.
119
+ */
120
+ get errors(): readonly FieldError[];
121
+ /**
122
+ * Checks if this relation has any errors.
123
+ */
124
+ get hasError(): boolean;
125
+ /**
126
+ * Adds a client-side error to this relation.
127
+ */
128
+ addError(error: ErrorInput): void;
129
+ /**
130
+ * Clears all errors from this relation.
131
+ */
132
+ clearErrors(): void;
133
+ /**
134
+ * Subscribe to connection events.
135
+ */
136
+ onConnect(listener: EventListener<RelationConnectedEvent>): Unsubscribe;
137
+ /**
138
+ * Subscribe to disconnection events.
139
+ */
140
+ onDisconnect(listener: EventListener<RelationDisconnectedEvent>): Unsubscribe;
141
+ /**
142
+ * Intercept connection (can cancel or modify target).
143
+ */
144
+ interceptConnect(interceptor: Interceptor<RelationConnectingEvent>): Unsubscribe;
145
+ /**
146
+ * Intercept disconnection (can cancel).
147
+ */
148
+ interceptDisconnect(interceptor: Interceptor<RelationDisconnectingEvent>): Unsubscribe;
149
+ /** Raw data snapshot of the related entity - delegates to $entity */
150
+ get $data(): TSelected | null;
151
+ /** Whether this entity is new - delegates to $entity */
152
+ get $isNew(): boolean;
153
+ /** Server-assigned ID after persistence - delegates to $entity */
154
+ get $persistedId(): string | null;
155
+ /** Type brand for entity name */
156
+ get __entityName(): string;
157
+ /** Clear all errors - delegates to $entity */
158
+ $clearAllErrors(): void;
159
+ /** Subscribe to any event on the related entity */
160
+ $on<E extends AfterEventTypes>(eventType: E, listener: EventListener<EventTypeMap[E]>): Unsubscribe;
161
+ /** Intercept any before event on the related entity */
162
+ $intercept<E extends BeforeEventTypes>(eventType: E, interceptor: Interceptor<EventTypeMap[E]>): Unsubscribe;
163
+ /** Subscribe to persist success events on the related entity */
164
+ $onPersisted(listener: EventListener<EntityPersistedEvent>): Unsubscribe;
165
+ /** Intercept persist on the related entity */
166
+ $interceptPersisting(interceptor: Interceptor<EntityPersistingEvent>): Unsubscribe;
167
+ }
168
+ //# sourceMappingURL=HasOneHandle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HasOneHandle.d.ts","sourceRoot":"","sources":["../../src/handles/HasOneHandle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAQ1D,OAAO,EACN,cAAc,EACd,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAqB,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACxF,OAAO,KAAK,EACX,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,MAAM,oBAAoB,CAAA;AAM3B;;;;;;GAMG;AACH,qBAAa,YAAY,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAAE,SAA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AAS,gBAAgB,EACpC,SAAS,EAAE,CAAC,EACZ,WAAW,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GACvC,WAAW;IAId,gEAAgE;IAChE,YAAY,CAAC,QAAQ,EAAE,aAAa,CAAC,oBAAoB,CAAC,GAAG,WAAW;IAIxE,8CAA8C;IAC9C,oBAAoB,CAAC,WAAW,EAAE,WAAW,CAAC,qBAAqB,CAAC,GAAG,WAAW;CAIlF"}
@@ -0,0 +1,117 @@
1
+ import type { ActionDispatcher } from '../core/ActionDispatcher.js';
2
+ import type { SnapshotStore } from '../store/SnapshotStore.js';
3
+ import { type EntityRef, type SelectedEntityFields, type Unsubscribe } from './types.js';
4
+ import type { ErrorInput, FieldError } from '../errors/types.js';
5
+ import type { EventTypeMap, AfterEventTypes, BeforeEventTypes, EventListener, Interceptor, EntityPersistedEvent, EntityPersistingEvent } from '../events/types.js';
6
+ /**
7
+ * PlaceholderHandle provides access to a placeholder entity (for creating new entities).
8
+ * Implements EntityRef interface with a placeholder ID.
9
+ * Reads/writes from placeholderData in the relation state.
10
+ *
11
+ * @typeParam TEntity - The full entity type
12
+ * @typeParam TSelected - The selected subset of fields
13
+ */
14
+ export declare class PlaceholderHandle<TEntity extends object = object, TSelected = TEntity> implements EntityRef<TEntity, TSelected> {
15
+ private readonly parentEntityType;
16
+ private readonly parentEntityId;
17
+ private readonly fieldName;
18
+ private readonly targetType;
19
+ private readonly store;
20
+ private readonly dispatcher;
21
+ /** Runtime brand symbols for validation */
22
+ readonly __brands?: Set<symbol>;
23
+ /** Type brand for schema - placeholder at runtime */
24
+ readonly __schema: Record<string, object>;
25
+ /** Placeholder ID for this handle */
26
+ private readonly placeholderId;
27
+ readonly $fields: SelectedEntityFields<TEntity, TSelected>;
28
+ readonly $data: TSelected | null;
29
+ readonly $isDirty: boolean;
30
+ readonly $persistedId: null;
31
+ readonly $isNew: boolean;
32
+ readonly $errors: readonly FieldError[];
33
+ readonly $hasError: boolean;
34
+ $addError: (error: ErrorInput) => void;
35
+ $clearErrors: () => void;
36
+ $clearAllErrors: () => void;
37
+ $on: <E extends AfterEventTypes>(eventType: E, listener: EventListener<EventTypeMap[E]>) => Unsubscribe;
38
+ $intercept: <E extends BeforeEventTypes>(eventType: E, interceptor: Interceptor<EventTypeMap[E]>) => Unsubscribe;
39
+ $onPersisted: (listener: EventListener<EntityPersistedEvent>) => Unsubscribe;
40
+ $interceptPersisting: (interceptor: Interceptor<EntityPersistingEvent>) => Unsubscribe;
41
+ private constructor();
42
+ static create<TEntity extends object = object, TSelected = TEntity>(parentEntityType: string, parentEntityId: string, fieldName: string, targetType: string, store: SnapshotStore, dispatcher: ActionDispatcher, brands?: Set<symbol>): PlaceholderHandle<TEntity, TSelected>;
43
+ /**
44
+ * Gets the placeholder ID.
45
+ */
46
+ get id(): string;
47
+ /**
48
+ * Gets placeholder data from the relation state.
49
+ */
50
+ get data(): TSelected | null;
51
+ /**
52
+ * Placeholder is dirty if it has any data.
53
+ */
54
+ get isDirty(): boolean;
55
+ /**
56
+ * Placeholder entities are always new (not yet persisted).
57
+ */
58
+ get persistedId(): null;
59
+ /**
60
+ * Placeholder entities are always new.
61
+ */
62
+ get isNew(): boolean;
63
+ /**
64
+ * Gets field accessors that read/write placeholder data.
65
+ */
66
+ get fields(): SelectedEntityFields<TEntity, TSelected>;
67
+ /**
68
+ * Creates a field handle for placeholder data.
69
+ */
70
+ private createPlaceholderFieldHandle;
71
+ /**
72
+ * Type brand for EntityRef compatibility.
73
+ */
74
+ get __entityType(): TEntity;
75
+ /**
76
+ * Entity name for type inference.
77
+ */
78
+ get __entityName(): string;
79
+ /**
80
+ * Placeholder entities don't have persistent errors.
81
+ * Returns empty array.
82
+ */
83
+ get errors(): readonly FieldError[];
84
+ /**
85
+ * Placeholder entities don't have errors.
86
+ */
87
+ get hasError(): boolean;
88
+ /**
89
+ * No-op for placeholder entities.
90
+ */
91
+ addError(_error: ErrorInput): void;
92
+ /**
93
+ * No-op for placeholder entities.
94
+ */
95
+ clearErrors(): void;
96
+ /**
97
+ * No-op for placeholder entities.
98
+ */
99
+ clearAllErrors(): void;
100
+ /**
101
+ * No-op for placeholder entities.
102
+ */
103
+ on<E extends AfterEventTypes>(_eventType: E, _listener: EventListener<EventTypeMap[E]>): Unsubscribe;
104
+ /**
105
+ * No-op for placeholder entities.
106
+ */
107
+ intercept<E extends BeforeEventTypes>(_eventType: E, _interceptor: Interceptor<EventTypeMap[E]>): Unsubscribe;
108
+ /**
109
+ * No-op for placeholder entities.
110
+ */
111
+ onPersisted(_listener: EventListener<EntityPersistedEvent>): Unsubscribe;
112
+ /**
113
+ * No-op for placeholder entities.
114
+ */
115
+ interceptPersisting(_interceptor: Interceptor<EntityPersistingEvent>): Unsubscribe;
116
+ }
117
+ //# sourceMappingURL=PlaceholderHandle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlaceholderHandle.d.ts","sourceRoot":"","sources":["../../src/handles/PlaceholderHandle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAE9D,OAAO,EAEN,KAAK,SAAS,EACd,KAAK,oBAAoB,EAEzB,KAAK,WAAW,EAChB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,KAAK,EACX,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,oBAAoB,EACpB,qBAAqB,EACrB,MAAM,oBAAoB,CAAA;AAG3B;;;;;;;GAOG;AACH,qBAAa,iBAAiB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAAE,SAAS,GAAG,OAAO,CAClF,YAAW,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC;IA4BvC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,C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AAE,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GACvC,WAAW;IAId;;OAEG;IACH,SAAS,CAAC,CAAC,SAAS,gBAAgB,EACnC,UAAU,EAAE,CAAC,EACb,YAAY,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GACxC,WAAW;IAId;;OAEG;IACH,WAAW,CAAC,SAAS,EAAE,aAAa,CAAC,oBAAoB,CAAC,GAAG,WAAW;IAIxE;;OAEG;IACH,mBAAmB,CAAC,YAAY,EAAE,WAAW,CAAC,qBAAqB,CAAC,GAAG,WAAW;CAIlF"}
@@ -0,0 +1,8 @@
1
+ export { BaseHandle, EntityRelatedHandle } from './BaseHandle.js';
2
+ export { FieldHandle } from './FieldHandle.js';
3
+ export { EntityHandle } from './EntityHandle.js';
4
+ export { HasOneHandle } from './HasOneHandle.js';
5
+ export { PlaceholderHandle } from './PlaceholderHandle.js';
6
+ export { HasManyListHandle } from './HasManyListHandle.js';
7
+ export { FIELD_REF_META, type HasOneRelationState, type EntityFields, type SelectedEntityFields, type SelectedEntityFieldsBase, type ScalarKeys, type HasManyKeys, type HasOneKeys, type FieldRefMeta, type InputProps, type FieldRef, type HasManyRef, type HasOneRef, type HasOneAccessor, type EntityRef, type EntityAccessor, type FieldRefBase, type HasManyRefBase, type HasOneRefBase, type HasOneAccessorBase, type EntityRefBase, type EntityAccessorBase, type Unsubscribe, type ExtractHasOneEntityName, type ExtractHasManyEntityName, type ExtractRoleMap, } from './types.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handles/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EACN,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,UAAU,EAEf,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,cAAc,EAEnB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAEhB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,cAAc,GACnB,MAAM,YAAY,CAAA"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Shared proxy factory for creating handle proxies with direct field access and $ aliasing.
3
+ *
4
+ * This module provides:
5
+ * 1. createHandleProxy - for EntityHandle/HasOneHandle with field access via proxy
6
+ * 2. createAliasProxy - for FieldHandle/HasManyListHandle/PlaceholderHandle with $ aliasing only
7
+ *
8
+ * The $ prefix convention allows handle properties to avoid collision with entity field names:
9
+ * - `entity.title` → field access (returns FieldHandle)
10
+ * - `entity.$isDirty` → handle property
11
+ */
12
+ /**
13
+ * Known properties on EntityHandle that should NOT be treated as field access.
14
+ * Properties like `fields`, `data`, `errors` are NOT included - use $ prefix for those.
15
+ */
16
+ export declare const ENTITY_HANDLE_PROPERTIES: Set<string | symbol>;
17
+ /**
18
+ * Known properties on HasOneHandle that should NOT be treated as field access.
19
+ * Properties like `fields`, `entity`, `errors`, `state` are NOT included - they require $ prefix.
20
+ */
21
+ export declare const HAS_ONE_HANDLE_PROPERTIES: Set<string | symbol>;
22
+ /**
23
+ * All properties on FieldHandle (no field access proxy needed, just $ aliasing).
24
+ */
25
+ export declare const FIELD_HANDLE_PROPERTIES: Set<string | symbol>;
26
+ /**
27
+ * All properties on HasManyListHandle (no field access proxy needed, just $ aliasing).
28
+ */
29
+ export declare const HAS_MANY_HANDLE_PROPERTIES: Set<string | symbol>;
30
+ /**
31
+ * All properties on PlaceholderHandle (no field access proxy needed, just $ aliasing).
32
+ */
33
+ export declare const PLACEHOLDER_HANDLE_PROPERTIES: Set<string | symbol>;
34
+ /**
35
+ * Configuration for creating a handle proxy.
36
+ */
37
+ export interface HandleProxyConfig<T extends object> {
38
+ /** Set of property names that should pass through to the handle */
39
+ knownProperties: Set<string | symbol>;
40
+ /** Function to get the fields proxy from the handle */
41
+ getFields: (target: T) => object;
42
+ }
43
+ /**
44
+ * Creates a proxy around a handle that supports direct field access.
45
+ *
46
+ * - `handle.fieldName` is equivalent to `handle.$fields.fieldName`
47
+ * - `handle.$propertyName` accesses handle properties with $ prefix stripped
48
+ * - Known properties pass through directly to the handle
49
+ *
50
+ * @param handle - The handle instance to wrap
51
+ * @param config - Configuration for the proxy
52
+ * @returns Proxied handle with direct field access support
53
+ */
54
+ export declare function createHandleProxy<T extends object>(handle: T, config: HandleProxyConfig<T>): T;
55
+ /**
56
+ * Creates a simple proxy that only handles $ prefix aliasing.
57
+ * Used for handles that don't need field access proxying (FieldHandle, HasManyListHandle, PlaceholderHandle).
58
+ *
59
+ * - `handle.$propertyName` accesses `handle.propertyName`
60
+ * - All other accesses pass through to the handle
61
+ *
62
+ * @param handle - The handle instance to wrap
63
+ * @returns Proxied handle with $ alias support
64
+ */
65
+ export declare function createAliasProxy<T extends object>(handle: T): T;
66
+ //# sourceMappingURL=proxyFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxyFactory.d.ts","sourceRoot":"","sources":["../../src/handles/proxyFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAqBH;;;GAGG;AACH,eAAO,MAAM,wBAAwB,sBAUnC,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,sBAOpC,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,sBAWlC,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,sBAcrC,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,6BAA6B,sBAWxC,CAAA;AAEF;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,MAAM;IAClD,mEAAmE;IACnE,eAAe,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAA;IACrC,uDAAuD;IACvD,SAAS,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,CAAA;CAChC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EACjD,MAAM,EAAE,CAAC,EACT,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC1B,CAAC,CA2CH;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CA2B/D"}