@contember/bindx-react 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 (194) hide show
  1. package/dist/batching/QueryBatcher.d.ts +31 -0
  2. package/dist/batching/QueryBatcher.d.ts.map +1 -0
  3. package/dist/batching/index.d.ts +2 -0
  4. package/dist/batching/index.d.ts.map +1 -0
  5. package/dist/components/EntityScope.d.ts +28 -0
  6. package/dist/components/EntityScope.d.ts.map +1 -0
  7. package/dist/dataview/DataGrid.d.ts +45 -0
  8. package/dist/dataview/DataGrid.d.ts.map +1 -0
  9. package/dist/dataview/DataGridPagination.d.ts +24 -0
  10. package/dist/dataview/DataGridPagination.d.ts.map +1 -0
  11. package/dist/dataview/DataGridToolbar.d.ts +16 -0
  12. package/dist/dataview/DataGridToolbar.d.ts.map +1 -0
  13. package/dist/dataview/DataViewContext.d.ts +32 -0
  14. package/dist/dataview/DataViewContext.d.ts.map +1 -0
  15. package/dist/dataview/columns.d.ts +115 -0
  16. package/dist/dataview/columns.d.ts.map +1 -0
  17. package/dist/dataview/contextHooks.d.ts +48 -0
  18. package/dist/dataview/contextHooks.d.ts.map +1 -0
  19. package/dist/dataview/dataAttribute.d.ts +6 -0
  20. package/dist/dataview/dataAttribute.d.ts.map +1 -0
  21. package/dist/dataview/export.d.ts +46 -0
  22. package/dist/dataview/export.d.ts.map +1 -0
  23. package/dist/dataview/filterComponents.d.ts +127 -0
  24. package/dist/dataview/filterComponents.d.ts.map +1 -0
  25. package/dist/dataview/filterContext.d.ts +10 -0
  26. package/dist/dataview/filterContext.d.ts.map +1 -0
  27. package/dist/dataview/filterHooks.d.ts +74 -0
  28. package/dist/dataview/filterHooks.d.ts.map +1 -0
  29. package/dist/dataview/filterScope.d.ts +54 -0
  30. package/dist/dataview/filterScope.d.ts.map +1 -0
  31. package/dist/dataview/filterWrappers.d.ts +65 -0
  32. package/dist/dataview/filterWrappers.d.ts.map +1 -0
  33. package/dist/dataview/index.d.ts +21 -0
  34. package/dist/dataview/index.d.ts.map +1 -0
  35. package/dist/dataview/infiniteLoad.d.ts +32 -0
  36. package/dist/dataview/infiniteLoad.d.ts.map +1 -0
  37. package/dist/dataview/loaderComponents.d.ts +80 -0
  38. package/dist/dataview/loaderComponents.d.ts.map +1 -0
  39. package/dist/dataview/pagingComponents.d.ts +50 -0
  40. package/dist/dataview/pagingComponents.d.ts.map +1 -0
  41. package/dist/dataview/renderCellValue.d.ts +9 -0
  42. package/dist/dataview/renderCellValue.d.ts.map +1 -0
  43. package/dist/dataview/selectionComponents.d.ts +62 -0
  44. package/dist/dataview/selectionComponents.d.ts.map +1 -0
  45. package/dist/dataview/sortingComponents.d.ts +39 -0
  46. package/dist/dataview/sortingComponents.d.ts.map +1 -0
  47. package/dist/dataview/stateStorage.d.ts +19 -0
  48. package/dist/dataview/stateStorage.d.ts.map +1 -0
  49. package/dist/dataview/useDataView.d.ts +58 -0
  50. package/dist/dataview/useDataView.d.ts.map +1 -0
  51. package/dist/dataview/useDataViewState.d.ts +89 -0
  52. package/dist/dataview/useDataViewState.d.ts.map +1 -0
  53. package/dist/hooks/BackendAdapterContext.d.ts +110 -0
  54. package/dist/hooks/BackendAdapterContext.d.ts.map +1 -0
  55. package/dist/hooks/ContemberBindxProvider.d.ts +67 -0
  56. package/dist/hooks/ContemberBindxProvider.d.ts.map +1 -0
  57. package/dist/hooks/createBindx.d.ts +39 -0
  58. package/dist/hooks/createBindx.d.ts.map +1 -0
  59. package/dist/hooks/index.d.ts +10 -0
  60. package/dist/hooks/index.d.ts.map +1 -0
  61. package/dist/hooks/useBindxEvents.d.ts +83 -0
  62. package/dist/hooks/useBindxEvents.d.ts.map +1 -0
  63. package/dist/hooks/useEntity.d.ts +123 -0
  64. package/dist/hooks/useEntity.d.ts.map +1 -0
  65. package/dist/hooks/useEntityBeforePersist.d.ts +22 -0
  66. package/dist/hooks/useEntityBeforePersist.d.ts.map +1 -0
  67. package/dist/hooks/useEntityCore.d.ts +52 -0
  68. package/dist/hooks/useEntityCore.d.ts.map +1 -0
  69. package/dist/hooks/useEntityImpl.d.ts +105 -0
  70. package/dist/hooks/useEntityImpl.d.ts.map +1 -0
  71. package/dist/hooks/useEntityList.d.ts +102 -0
  72. package/dist/hooks/useEntityList.d.ts.map +1 -0
  73. package/dist/hooks/useEntityListCore.d.ts +49 -0
  74. package/dist/hooks/useEntityListCore.d.ts.map +1 -0
  75. package/dist/hooks/useEntityListImpl.d.ts +70 -0
  76. package/dist/hooks/useEntityListImpl.d.ts.map +1 -0
  77. package/dist/hooks/useErrors.d.ts +72 -0
  78. package/dist/hooks/useErrors.d.ts.map +1 -0
  79. package/dist/hooks/usePersist.d.ts +115 -0
  80. package/dist/hooks/usePersist.d.ts.map +1 -0
  81. package/dist/hooks/useSelectionCollection.d.ts +41 -0
  82. package/dist/hooks/useSelectionCollection.d.ts.map +1 -0
  83. package/dist/hooks/useSelectionCollectionForList.d.ts +40 -0
  84. package/dist/hooks/useSelectionCollectionForList.d.ts.map +1 -0
  85. package/dist/hooks/useStableSelectionMeta.d.ts +11 -0
  86. package/dist/hooks/useStableSelectionMeta.d.ts.map +1 -0
  87. package/dist/hooks/useStoreSubscription.d.ts +19 -0
  88. package/dist/hooks/useStoreSubscription.d.ts.map +1 -0
  89. package/dist/hooks/useUndo.d.ts +45 -0
  90. package/dist/hooks/useUndo.d.ts.map +1 -0
  91. package/dist/index.d.ts +17 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/jsx/SelectionMeta.d.ts +2 -0
  94. package/dist/jsx/SelectionMeta.d.ts.map +1 -0
  95. package/dist/jsx/analyzer.d.ts +22 -0
  96. package/dist/jsx/analyzer.d.ts.map +1 -0
  97. package/dist/jsx/collectorProxy.d.ts +14 -0
  98. package/dist/jsx/collectorProxy.d.ts.map +1 -0
  99. package/dist/jsx/componentBuilder.d.ts +51 -0
  100. package/dist/jsx/componentBuilder.d.ts.map +1 -0
  101. package/dist/jsx/componentBuilder.types.d.ts +268 -0
  102. package/dist/jsx/componentBuilder.types.d.ts.map +1 -0
  103. package/dist/jsx/componentBuilderCompat.d.ts +17 -0
  104. package/dist/jsx/componentBuilderCompat.d.ts.map +1 -0
  105. package/dist/jsx/componentFactory.d.ts +39 -0
  106. package/dist/jsx/componentFactory.d.ts.map +1 -0
  107. package/dist/jsx/components/Entity.d.ts +82 -0
  108. package/dist/jsx/components/Entity.d.ts.map +1 -0
  109. package/dist/jsx/components/EntityList.d.ts +48 -0
  110. package/dist/jsx/components/EntityList.d.ts.map +1 -0
  111. package/dist/jsx/components/Field.d.ts +27 -0
  112. package/dist/jsx/components/Field.d.ts.map +1 -0
  113. package/dist/jsx/components/HasMany.d.ts +34 -0
  114. package/dist/jsx/components/HasMany.d.ts.map +1 -0
  115. package/dist/jsx/components/HasOne.d.ts +25 -0
  116. package/dist/jsx/components/HasOne.d.ts.map +1 -0
  117. package/dist/jsx/components/HasRole.d.ts +51 -0
  118. package/dist/jsx/components/HasRole.d.ts.map +1 -0
  119. package/dist/jsx/components/If.d.ts +51 -0
  120. package/dist/jsx/components/If.d.ts.map +1 -0
  121. package/dist/jsx/components/Show.d.ts +33 -0
  122. package/dist/jsx/components/Show.d.ts.map +1 -0
  123. package/dist/jsx/components/index.d.ts +8 -0
  124. package/dist/jsx/components/index.d.ts.map +1 -0
  125. package/dist/jsx/conditions.d.ts +310 -0
  126. package/dist/jsx/conditions.d.ts.map +1 -0
  127. package/dist/jsx/createComponent.d.ts +44 -0
  128. package/dist/jsx/createComponent.d.ts.map +1 -0
  129. package/dist/jsx/index.d.ts +19 -0
  130. package/dist/jsx/index.d.ts.map +1 -0
  131. package/dist/jsx/inlineProxy.d.ts +14 -0
  132. package/dist/jsx/inlineProxy.d.ts.map +1 -0
  133. package/dist/jsx/legacyTypes.d.ts +26 -0
  134. package/dist/jsx/legacyTypes.d.ts.map +1 -0
  135. package/dist/jsx/proxy.d.ts +2 -0
  136. package/dist/jsx/proxy.d.ts.map +1 -0
  137. package/dist/jsx/proxyShared.d.ts +14 -0
  138. package/dist/jsx/proxyShared.d.ts.map +1 -0
  139. package/dist/jsx/runtimeProxy.d.ts +11 -0
  140. package/dist/jsx/runtimeProxy.d.ts.map +1 -0
  141. package/dist/jsx/standaloneCreateComponent.d.ts +30 -0
  142. package/dist/jsx/standaloneCreateComponent.d.ts.map +1 -0
  143. package/dist/jsx/types.d.ts +109 -0
  144. package/dist/jsx/types.d.ts.map +1 -0
  145. package/dist/jsx/withCollector.d.ts +39 -0
  146. package/dist/jsx/withCollector.d.ts.map +1 -0
  147. package/dist/roles/RoleContext.d.ts +31 -0
  148. package/dist/roles/RoleContext.d.ts.map +1 -0
  149. package/dist/roles/index.d.ts +2 -0
  150. package/dist/roles/index.d.ts.map +1 -0
  151. package/package.json +34 -0
  152. package/src/batching/QueryBatcher.ts +114 -0
  153. package/src/batching/index.ts +1 -0
  154. package/src/components/EntityScope.tsx +43 -0
  155. package/src/hooks/BackendAdapterContext.tsx +214 -0
  156. package/src/hooks/ContemberBindxProvider.tsx +158 -0
  157. package/src/hooks/index.ts +61 -0
  158. package/src/hooks/useBindxEvents.ts +229 -0
  159. package/src/hooks/useEntity.ts +489 -0
  160. package/src/hooks/useEntityBeforePersist.ts +32 -0
  161. package/src/hooks/useEntityList.ts +444 -0
  162. package/src/hooks/useErrors.ts +150 -0
  163. package/src/hooks/usePersist.ts +377 -0
  164. package/src/hooks/useSelectionCollection.ts +122 -0
  165. package/src/hooks/useStoreSubscription.ts +51 -0
  166. package/src/hooks/useUndo.ts +83 -0
  167. package/src/index.ts +357 -0
  168. package/src/jsx/SelectionMeta.ts +2 -0
  169. package/src/jsx/analyzer.ts +261 -0
  170. package/src/jsx/collectorProxy.ts +282 -0
  171. package/src/jsx/componentBuilder.ts +180 -0
  172. package/src/jsx/componentBuilder.types.ts +463 -0
  173. package/src/jsx/componentBuilderCompat.ts +39 -0
  174. package/src/jsx/componentFactory.ts +400 -0
  175. package/src/jsx/components/Entity.tsx +383 -0
  176. package/src/jsx/components/EntityList.tsx +147 -0
  177. package/src/jsx/components/Field.tsx +79 -0
  178. package/src/jsx/components/HasMany.tsx +109 -0
  179. package/src/jsx/components/HasOne.tsx +78 -0
  180. package/src/jsx/components/HasRole.tsx +95 -0
  181. package/src/jsx/components/If.tsx +127 -0
  182. package/src/jsx/components/Show.tsx +56 -0
  183. package/src/jsx/components/index.ts +20 -0
  184. package/src/jsx/conditions.ts +472 -0
  185. package/src/jsx/createComponent.ts +175 -0
  186. package/src/jsx/index.ts +135 -0
  187. package/src/jsx/legacyTypes.ts +30 -0
  188. package/src/jsx/proxy.ts +1 -0
  189. package/src/jsx/proxyShared.ts +42 -0
  190. package/src/jsx/standaloneCreateComponent.ts +47 -0
  191. package/src/jsx/types.ts +192 -0
  192. package/src/jsx/withCollector.ts +45 -0
  193. package/src/roles/RoleContext.tsx +57 -0
  194. package/src/roles/index.ts +1 -0
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Convenience hook to run a callback before an entity is persisted.
3
+ *
4
+ * This is useful for validation, cleanup, or other pre-persist logic.
5
+ * The callback is called before the entity is sent to the server.
6
+ *
7
+ * @example
8
+ * ```tsx
9
+ * function ArticleForm({ article }: { article: EntityRef<Article> }) {
10
+ * useEntityBeforePersist('Article', article.id, () => {
11
+ * // Validate or perform cleanup before persist
12
+ * if (!article.$fields.title.value) {
13
+ * article.$fields.title.addError('Title is required')
14
+ * }
15
+ * })
16
+ *
17
+ * return <form>...</form>
18
+ * }
19
+ * ```
20
+ */
21
+ export declare function useEntityBeforePersist(entityType: string, entityId: string, callback: () => void): void;
22
+ //# sourceMappingURL=useEntityBeforePersist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEntityBeforePersist.d.ts","sourceRoot":"","sources":["../../src/hooks/useEntityBeforePersist.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,sBAAsB,CACrC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,IAAI,GAClB,IAAI,CAKN"}
@@ -0,0 +1,52 @@
1
+ import type { SelectionMeta, EntityUniqueWhere, FieldError } from '@contember/bindx';
2
+ import type { EntitySnapshot, LoadStatus } from '@contember/bindx';
3
+ /**
4
+ * Options for useEntityCore hook.
5
+ */
6
+ export interface UseEntityCoreOptions {
7
+ /** Entity type name */
8
+ entityType: string;
9
+ /** Unique field(s) to identify the entity (e.g., { id: '...' } or { slug: '...' }) */
10
+ by: EntityUniqueWhere;
11
+ /** Pre-resolved selection metadata */
12
+ selectionMeta: SelectionMeta;
13
+ /** Optional query key for cache invalidation (used by JSX pattern) */
14
+ queryKey?: string;
15
+ /** Whether to use cached data if available */
16
+ cache?: boolean;
17
+ }
18
+ /**
19
+ * Load state from store
20
+ */
21
+ interface LoadState {
22
+ status: LoadStatus;
23
+ error?: FieldError;
24
+ }
25
+ /**
26
+ * Result from useEntityCore hook.
27
+ */
28
+ export interface EntityCoreResult {
29
+ /** Current load status */
30
+ status: 'loading' | 'error' | 'not_found' | 'ready';
31
+ /** Error if status is 'error' */
32
+ error?: FieldError;
33
+ /** Entity snapshot when ready */
34
+ snapshot: EntitySnapshot | undefined;
35
+ /** Load state from store */
36
+ loadState: LoadState | undefined;
37
+ /** Whether entity is being persisted */
38
+ isPersisting: boolean;
39
+ }
40
+ /**
41
+ * Core hook for entity data loading.
42
+ * Handles store subscription, data fetching, and state management.
43
+ *
44
+ * This hook accepts pre-resolved SelectionMeta, allowing it to be used by:
45
+ * - useEntity (which resolves fluent builder to SelectionMeta)
46
+ * - Entity component (which collects JSX selection to SelectionMeta)
47
+ *
48
+ * @internal This hook is for internal use only.
49
+ */
50
+ export declare function useEntityCore(options: UseEntityCoreOptions): EntityCoreResult;
51
+ export {};
52
+ //# sourceMappingURL=useEntityCore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEntityCore.d.ts","sourceRoot":"","sources":["../../src/hooks/useEntityCore.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACpF,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,sFAAsF;IACtF,EAAE,EAAE,iBAAiB,CAAA;IACrB,sCAAsC;IACtC,aAAa,EAAE,aAAa,CAAA;IAC5B,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAA;CACf;AAED;;GAEG;AACH,UAAU,SAAS;IAClB,MAAM,EAAE,UAAU,CAAA;IAClB,KAAK,CAAC,EAAE,UAAU,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,0BAA0B;IAC1B,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,OAAO,CAAA;IACnD,iCAAiC;IACjC,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,iCAAiC;IACjC,QAAQ,EAAE,cAAc,GAAG,SAAS,CAAA;IACpC,4BAA4B;IAC5B,SAAS,EAAE,SAAS,GAAG,SAAS,CAAA;IAChC,wCAAwC;IACxC,YAAY,EAAE,OAAO,CAAA;CACrB;AAWD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,gBAAgB,CA0L7E"}
@@ -0,0 +1,105 @@
1
+ import type { SchemaRegistry, EntityUniqueWhere, FieldError } from '@contember/bindx';
2
+ import type { SelectionMeta } from '@contember/bindx';
3
+ import type { SelectedEntityFields } from '@contember/bindx';
4
+ /**
5
+ * Options for useEntity hook
6
+ */
7
+ export interface UseEntityOptions {
8
+ /** Unique field(s) to identify the entity (e.g., { id: '...' } or { slug: '...' }) */
9
+ by: EntityUniqueWhere;
10
+ /** If true, use cached data from store if available (default: false) */
11
+ cache?: boolean;
12
+ }
13
+ /**
14
+ * Loading state for entity accessor
15
+ */
16
+ export interface LoadingEntityAccessor {
17
+ readonly status: 'loading';
18
+ readonly isLoading: true;
19
+ readonly isError: false;
20
+ readonly isNotFound: false;
21
+ readonly isPersisting: false;
22
+ readonly isDirty: false;
23
+ readonly id: string;
24
+ readonly fields: never;
25
+ readonly data: never;
26
+ persist(): Promise<void>;
27
+ reset(): void;
28
+ }
29
+ /**
30
+ * Error state for entity accessor
31
+ */
32
+ export interface ErrorEntityAccessor {
33
+ readonly status: 'error';
34
+ readonly isLoading: false;
35
+ readonly isError: true;
36
+ readonly isNotFound: false;
37
+ readonly error: FieldError;
38
+ readonly isPersisting: false;
39
+ readonly isDirty: false;
40
+ readonly id: string;
41
+ readonly fields: never;
42
+ readonly data: never;
43
+ persist(): Promise<void>;
44
+ reset(): void;
45
+ }
46
+ /**
47
+ * Not found state for entity accessor
48
+ */
49
+ export interface NotFoundEntityAccessor {
50
+ readonly status: 'not_found';
51
+ readonly isLoading: false;
52
+ readonly isError: false;
53
+ readonly isNotFound: true;
54
+ readonly isPersisting: false;
55
+ readonly isDirty: false;
56
+ readonly id: string;
57
+ readonly fields: never;
58
+ readonly data: never;
59
+ persist(): Promise<void>;
60
+ reset(): void;
61
+ }
62
+ /**
63
+ * Ready state base interface for entity accessor
64
+ *
65
+ * @typeParam TEntity - The full entity type
66
+ * @typeParam TSelected - The selected subset of fields (defaults to TEntity for backwards compatibility)
67
+ */
68
+ export interface ReadyEntityAccessorBase<TEntity extends object, TSelected extends object = TEntity> {
69
+ readonly status: 'ready';
70
+ readonly isLoading: false;
71
+ readonly isError: false;
72
+ readonly isNotFound: false;
73
+ readonly isPersisting: boolean;
74
+ readonly isDirty: boolean;
75
+ readonly id: string;
76
+ readonly fields: SelectedEntityFields<TEntity, TSelected>;
77
+ readonly data: TSelected;
78
+ persist(): Promise<void>;
79
+ reset(): void;
80
+ }
81
+ /**
82
+ * Ready state for entity accessor with direct field access via Proxy.
83
+ * Access fields directly: `entity.fieldName` instead of `entity.fields.fieldName`.
84
+ *
85
+ * @typeParam TEntity - The full entity type
86
+ * @typeParam TSelected - The selected subset of fields (defaults to TEntity for backwards compatibility)
87
+ */
88
+ export type ReadyEntityAccessor<TEntity extends object, TSelected extends object = TEntity> = ReadyEntityAccessorBase<TEntity, TSelected> & SelectedEntityFields<TEntity, TSelected>;
89
+ /**
90
+ * Union of all entity accessor states
91
+ *
92
+ * @typeParam TEntity - The full entity type
93
+ * @typeParam TSelected - The selected subset of fields (defaults to TEntity for backwards compatibility)
94
+ */
95
+ export type EntityAccessorResult<TEntity extends object, TSelected extends object = TEntity> = LoadingEntityAccessor | ErrorEntityAccessor | NotFoundEntityAccessor | ReadyEntityAccessor<TEntity, TSelected>;
96
+ /**
97
+ * Generic implementation of useEntity hook.
98
+ * Used by createBindx to create typed versions.
99
+ *
100
+ * @typeParam TEntity - The full entity type
101
+ * @typeParam TSelected - The selected subset of fields
102
+ * @internal
103
+ */
104
+ export declare function useEntityImpl<TEntity extends object, TSelected extends object>(entityType: string, options: UseEntityOptions, selectionMeta: SelectionMeta, schema: SchemaRegistry<Record<string, object>>): EntityAccessorResult<TEntity, TSelected>;
105
+ //# sourceMappingURL=useEntityImpl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEntityImpl.d.ts","sourceRoot":"","sources":["../../src/hooks/useEntityImpl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAKrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAgB,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAE1E;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,sFAAsF;IACtF,EAAE,EAAE,iBAAiB,CAAA;IACrB,wEAAwE;IACxE,KAAK,CAAC,EAAE,OAA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MAAM,EAAE,SAAS,SAAS,MAAM,GAAG,OAAO,IACxF,qBAAqB,GACrB,mBAAmB,GACnB,sBAAsB,GACtB,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;AAoF1C;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,SAAS,MAAM,EAAE,SAAS,SAAS,MAAM,EAC7E,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAC5C,oBAAoB,CAAC,OAAO,EAAE,SAAS,CAAC,CA+F1C"}
@@ -0,0 +1,102 @@
1
+ import type { EntityDef, EntityAccessor, SelectionInput, SelectionMeta, FieldError, CommonEntity, EntityForRoles, RoleNames } from '@contember/bindx';
2
+ /**
3
+ * Options for useEntityList hook
4
+ */
5
+ export interface UseEntityListOptions {
6
+ /** Optional filter criteria */
7
+ filter?: Record<string, unknown>;
8
+ /** Optional ordering */
9
+ orderBy?: readonly Record<string, unknown>[];
10
+ /** Optional limit */
11
+ limit?: number;
12
+ /** Optional offset */
13
+ offset?: number;
14
+ /**
15
+ * Pre-resolved selection metadata.
16
+ * When provided, definer (3rd argument) is not needed.
17
+ * Used internally by EntityList, DataGrid, and DataView components.
18
+ */
19
+ selection?: SelectionMeta;
20
+ /** Optional query key for cache invalidation */
21
+ queryKey?: string;
22
+ }
23
+ /**
24
+ * Loading state for entity list accessor
25
+ */
26
+ export interface LoadingEntityListAccessor {
27
+ readonly status: 'loading';
28
+ readonly isLoading: true;
29
+ readonly isError: false;
30
+ readonly isDirty: false;
31
+ readonly items: never;
32
+ readonly length: 0;
33
+ add(data?: unknown): string;
34
+ remove(key: string): void;
35
+ move(fromIndex: number, toIndex: number): void;
36
+ }
37
+ /**
38
+ * Error state for entity list accessor
39
+ */
40
+ export interface ErrorEntityListAccessor {
41
+ readonly status: 'error';
42
+ readonly isLoading: false;
43
+ readonly isError: true;
44
+ readonly error: FieldError;
45
+ readonly isDirty: false;
46
+ readonly items: never;
47
+ readonly length: 0;
48
+ add(data?: unknown): string;
49
+ remove(key: string): void;
50
+ move(fromIndex: number, toIndex: number): void;
51
+ }
52
+ /**
53
+ * Ready state for entity list accessor
54
+ */
55
+ export interface ReadyEntityListAccessor<T extends object> {
56
+ readonly status: 'ready';
57
+ readonly isLoading: false;
58
+ readonly isError: false;
59
+ readonly isDirty: boolean;
60
+ readonly items: Array<EntityAccessor<T>>;
61
+ readonly length: number;
62
+ add(data?: Partial<T>): string;
63
+ remove(key: string): void;
64
+ move(fromIndex: number, toIndex: number): void;
65
+ }
66
+ /**
67
+ * Union of all entity list accessor states
68
+ */
69
+ export type EntityListAccessorResult<T extends object> = LoadingEntityListAccessor | ErrorEntityListAccessor | ReadyEntityListAccessor<T>;
70
+ /**
71
+ * Hook to fetch and manage a list of entities with role-expanded type inference.
72
+ *
73
+ * @example
74
+ * ```tsx
75
+ * const authors = useEntityList(schema.Author, { roles: ['admin'] }, e => e.name().internalNotes())
76
+ * ```
77
+ */
78
+ export declare function useEntityList<TRoleMap extends Record<string, object>, TRoles extends RoleNames<TRoleMap>, TResult extends object>(entity: EntityDef<TRoleMap>, options: UseEntityListOptions & {
79
+ roles: readonly TRoles[];
80
+ }, definer: SelectionInput<EntityForRoles<TRoleMap, TRoles>, TResult>): EntityListAccessorResult<TResult>;
81
+ /**
82
+ * Hook to fetch and manage a list of entities with full type inference.
83
+ * Uses the common (narrowest) entity type when no roles are specified.
84
+ *
85
+ * @example
86
+ * ```tsx
87
+ * const authors = useEntityList(schema.Author, {}, e => e.name().email())
88
+ * if (authors.status !== 'ready') return <Loading />
89
+ * return authors.items.map(a => <div key={a.id}>{a.name.value}</div>)
90
+ * ```
91
+ */
92
+ export declare function useEntityList<TRoleMap extends Record<string, object>, TResult extends object>(entity: EntityDef<TRoleMap>, options: UseEntityListOptions, definer: SelectionInput<CommonEntity<TRoleMap>, TResult>): EntityListAccessorResult<TResult>;
93
+ /**
94
+ * Hook to fetch and manage a list of entities with pre-resolved selection.
95
+ *
96
+ * Used internally by EntityList, DataGrid, and DataView components
97
+ * that collect selection from JSX before calling this hook.
98
+ */
99
+ export declare function useEntityList(entity: EntityDef, options: UseEntityListOptions & {
100
+ selection: SelectionMeta;
101
+ }): EntityListAccessorResult<object>;
102
+ //# sourceMappingURL=useEntityList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEntityList.d.ts","sourceRoot":"","sources":["../../src/hooks/useEntityList.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,UAAU,EAAkB,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AASrK;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,wBAAwB;IACxB,OAAO,CAAC,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAC5C,qBAAqB;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;OAIG;IACH,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB;AAMD;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;IAC1B,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAA;IACxB,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;IAClB,GA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** Entity type name */
7
+ entityType: string;
8
+ /** Optional filter criteria */
9
+ filter?: Record<string, unknown>;
10
+ /** Optional ordering */
11
+ orderBy?: readonly Record<string, unknown>[];
12
+ /** Optional limit */
13
+ limit?: number;
14
+ /** Optional offset */
15
+ offset?: number;
16
+ /** Pre-resolved selection metadata */
17
+ selectionMeta: SelectionMeta;
18
+ /** Optional query key for cache invalidation */
19
+ queryKey?: string;
20
+ }
21
+ /**
22
+ * Item in the entity list result
23
+ */
24
+ export interface EntityListCoreItem {
25
+ id: string;
26
+ data: Record<string, unknown>;
27
+ }
28
+ /**
29
+ * Result from useEntityListCore hook.
30
+ */
31
+ export interface EntityListCoreResult {
32
+ /** Current load status */
33
+ status: 'loading' | 'error' | 'ready';
34
+ /** Error if status is 'error' */
35
+ error?: FieldError;
36
+ /** List items when ready */
37
+ items: EntityListCoreItem[];
38
+ }
39
+ /**
40
+ * Core hook for entity list data loading.
41
+ * Handles store subscription, data fetching, and state management.
42
+ *
43
+ * This hook accepts pre-resolved SelectionMeta, allowing it to be used by:
44
+ * - EntityList component (which collects JSX selection to SelectionMeta)
45
+ *
46
+ * @internal This hook is for internal use only.
47
+ */
48
+ export declare function useEntityListCore(options: UseEntityListCoreOptions): EntityListCoreResult;
49
+ //# sourceMappingURL=useEntityListCore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEntityListCore.d.ts","sourceRoot":"","sources":["../../src/hooks/useEntityListCore.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAEjE;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,wBAAwB;IACxB,OAAO,CAAC,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAC5C,qBAAqB;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,sCAAsC;IACtC,aAAa,EAAE,aAAa,CAAA;IAC5B,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,0BAA0B;IAC1B,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,OAAO,CAAA;IACrC,iCAAiC;IACjC,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,4BAA4B;IAC5B,KAAK,EAAE,kBAAkB,EAAE,CAAA;CAC3B;AAWD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,oBAAoB,CAkKzF"}
@@ -0,0 +1,70 @@
1
+ import type { SchemaRegistry, EntityAccessor } from '@contember/bindx';
2
+ import type { SelectionMeta, FieldError } from '@contember/bindx';
3
+ /**
4
+ * Options for useEntityList hook
5
+ */
6
+ export interface UseEntityListOptions {
7
+ /** Optional filter criteria */
8
+ filter?: Record<string, unknown>;
9
+ /** Optional ordering */
10
+ orderBy?: readonly Record<string, unknown>[];
11
+ /** Optional limit */
12
+ limit?: number;
13
+ /** Optional offset */
14
+ offset?: number;
15
+ }
16
+ /**
17
+ * Loading state for entity list accessor
18
+ */
19
+ export interface LoadingEntityListAccessor {
20
+ readonly status: 'loading';
21
+ readonly isLoading: true;
22
+ readonly isError: false;
23
+ readonly isDirty: false;
24
+ readonly items: never;
25
+ readonly length: 0;
26
+ add(data?: unknown): string;
27
+ remove(key: string): void;
28
+ move(fromIndex: number, toIndex: number): void;
29
+ }
30
+ /**
31
+ * Error state for entity list accessor
32
+ */
33
+ export interface ErrorEntityListAccessor {
34
+ readonly status: 'error';
35
+ readonly isLoading: false;
36
+ readonly isError: true;
37
+ readonly error: FieldError;
38
+ readonly isDirty: false;
39
+ readonly items: never;
40
+ readonly length: 0;
41
+ add(data?: unknown): string;
42
+ remove(key: string): void;
43
+ move(fromIndex: number, toIndex: number): void;
44
+ }
45
+ /**
46
+ * Ready state for entity list accessor
47
+ */
48
+ export interface ReadyEntityListAccessor<T extends object> {
49
+ readonly status: 'ready';
50
+ readonly isLoading: false;
51
+ readonly isError: false;
52
+ readonly isDirty: boolean;
53
+ readonly items: Array<EntityAccessor<T>>;
54
+ readonly length: number;
55
+ add(data?: Partial<T>): string;
56
+ remove(key: string): void;
57
+ move(fromIndex: number, toIndex: number): void;
58
+ }
59
+ /**
60
+ * Union of all entity list accessor states
61
+ */
62
+ export type EntityListAccessorResult<T extends object> = LoadingEntityListAccessor | ErrorEntityListAccessor | ReadyEntityListAccessor<T>;
63
+ /**
64
+ * Generic implementation of useEntityList hook.
65
+ * Used by createBindx to create typed versions.
66
+ *
67
+ * @internal
68
+ */
69
+ export declare function useEntityListImpl<TResult extends object>(entityType: string, options: UseEntityListOptions, selectionMeta: SelectionMeta, schema: SchemaRegistry<Record<string, object>>): EntityListAccessorResult<TResult>;
70
+ //# sourceMappingURL=useEntityListImpl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEntityListImpl.d.ts","sourceRoot":"","sources":["../../src/hooks/useEntityListImpl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAMtE,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAEjE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,wBAAwB;IACxB,OAAO,CAAC,EAAE,SAA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uB,CAAC,CAAC,SAAS,MAAM;IACxD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAA;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAA;IAC9B,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9C;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,CAAC,CAAC,SAAS,MAAM,IAClD,yBAAyB,GACzB,uBAAuB,GACvB,uBAAuB,CAAC,CAAC,CAAC,CAAA;AA+C7B;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,MAAM,EACvD,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,EAC7B,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAC5C,wBAAwB,CAAC,OAAO,CAAC,CA+OnC"}
@@ -0,0 +1,72 @@
1
+ import type { FieldError } from '@contember/bindx';
2
+ /**
3
+ * Error state for an entity, including all field and relation errors.
4
+ */
5
+ export interface EntityErrorsState {
6
+ /** Entity-level errors */
7
+ readonly entityErrors: readonly FieldError[];
8
+ /** Field errors keyed by field name */
9
+ readonly fieldErrors: ReadonlyMap<string, readonly FieldError[]>;
10
+ /** Relation errors keyed by relation name */
11
+ readonly relationErrors: ReadonlyMap<string, readonly FieldError[]>;
12
+ /** Whether the entity has any errors */
13
+ readonly hasErrors: boolean;
14
+ /** Whether the entity has any client-side errors */
15
+ readonly hasClientErrors: boolean;
16
+ /** Whether the entity has any server-side errors */
17
+ readonly hasServerErrors: boolean;
18
+ /** All errors as a flat array */
19
+ readonly allErrors: readonly FieldError[];
20
+ }
21
+ /**
22
+ * Hook for accessing error state for a specific entity.
23
+ * Provides reactive access to entity, field, and relation errors.
24
+ *
25
+ * @example
26
+ * ```tsx
27
+ * function ArticleEditor({ id }: { id: string }) {
28
+ * const { hasErrors, entityErrors, fieldErrors } = useEntityErrors('Article', id)
29
+ *
30
+ * return (
31
+ * <div>
32
+ * {hasErrors && (
33
+ * <div className="error-banner">
34
+ * There are validation errors. Please fix them before saving.
35
+ * </div>
36
+ * )}
37
+ * {entityErrors.map(e => <p key={e.message}>{e.message}</p>)}
38
+ * </div>
39
+ * )
40
+ * }
41
+ * ```
42
+ */
43
+ export declare function useEntityErrors(entityType: string, entityId: string): EntityErrorsState;
44
+ /**
45
+ * Hook for accessing persistence error state from the most recent persist operation.
46
+ * Useful for displaying a summary of what went wrong during persistence.
47
+ *
48
+ * @example
49
+ * ```tsx
50
+ * function SaveButton() {
51
+ * const { persistAll } = usePersist()
52
+ * const [lastResult, setLastResult] = useState<PersistenceResult | null>(null)
53
+ *
54
+ * const handleSave = async () => {
55
+ * const result = await persistAll({ rollbackOnError: true })
56
+ * setLastResult(result)
57
+ * }
58
+ *
59
+ * return (
60
+ * <div>
61
+ * <button onClick={handleSave}>Save</button>
62
+ * {lastResult && !lastResult.success && (
63
+ * <div className="error">
64
+ * Failed to save {lastResult.failedCount} items
65
+ * </div>
66
+ * )}
67
+ * </div>
68
+ * )
69
+ * }
70
+ * ```
71
+ */
72
+ //# sourceMappingURL=useErrors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useErrors.d.ts","sourceRoot":"","sources":["../../src/hooks/useErrors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAGlD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,0BAA0B;IAC1B,QAAQ,CAAC,YAAY,EAAE,SAAS,UAAU,EAAE,CAAA;IAC5C,uCAAuC;IACvC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC,CAAA;IAChE,6CAA6C;IAC7C,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC,CAAA;IACnE,wCAAwC;IACxC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;IACjC,oDAAoD;IACpD,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;IACjC,iCAAiC;IACjC,QAAQ,CAAC,SAAS,EAAE,SAAS,UAAU,EAAE,CAAA;CACzC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,iBAAiB,CAwEvF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG"}
@@ -0,0 +1,115 @@
1
+ import { FIELD_REF_META, type DirtyEntity, type EntityPersistResult, type PersistenceResult, type PersistScope, type BatchPersistOptions, type FieldRefMeta } from '@contember/bindx';
2
+ /**
3
+ * Any ref that has entity metadata (FieldRef, HasOneRef, HasManyRef)
4
+ */
5
+ export type AnyRefWithMeta = {
6
+ readonly [FIELD_REF_META]: FieldRefMeta;
7
+ };
8
+ /**
9
+ * API returned by usePersist hook
10
+ */
11
+ export interface PersistApi {
12
+ /** Persist all dirty entities in a transaction */
13
+ persistAll(options?: BatchPersistOptions): Promise<PersistenceResult>;
14
+ /**
15
+ * Persist a single entity.
16
+ * Can be called with entityType/entityId or with a ref (FieldRef, HasOneRef, HasManyRef).
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * // With entityType and entityId
21
+ * persist('Article', 'abc-123')
22
+ *
23
+ * // With a FieldRef - persists the entity the field belongs to
24
+ * persist(article.fields.title)
25
+ * ```
26
+ */
27
+ persist(ref: AnyRefWithMeta, options?: BatchPersistOptions): Promise<EntityPersistResult>;
28
+ persist(entityType: string, entityId: string, options?: BatchPersistOptions): Promise<EntityPersistResult>;
29
+ /**
30
+ * Persist specific fields of an entity.
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * // With entityType, entityId, and field names
35
+ * persistFields('Article', 'abc-123', ['title', 'content'])
36
+ *
37
+ * // With a FieldRef - persists just that field
38
+ * persistFields(article.fields.title)
39
+ * ```
40
+ */
41
+ persistFields(ref: AnyRefWithMeta, options?: BatchPersistOptions): Promise<EntityPersistResult>;
42
+ persistFields(entityType: string, entityId: string, fields: readonly string[], options?: BatchPersistOptions): Promise<EntityPersistResult>;
43
+ /** Persist with custom scope */
44
+ persistScope(scope: PersistScope, options?: BatchPersistOptions): Promise<PersistenceResult>;
45
+ /** Check if any entity is currently being persisted */
46
+ isPersisting: boolean;
47
+ /** Get all dirty entities */
48
+ dirtyEntities: readonly DirtyEntity[];
49
+ /** Check if there are any dirty entities */
50
+ isDirty: boolean;
51
+ }
52
+ /**
53
+ * Hook for accessing the persistence API.
54
+ * Provides methods to persist all dirty entities, a single entity, or specific fields.
55
+ *
56
+ * @example
57
+ * ```tsx
58
+ * function SaveButton() {
59
+ * const { persistAll, isPersisting, isDirty } = usePersist()
60
+ *
61
+ * return (
62
+ * <button
63
+ * onClick={() => persistAll()}
64
+ * disabled={isPersisting || !isDirty}
65
+ * >
66
+ * {isPersisting ? 'Saving...' : 'Save All'}
67
+ * </button>
68
+ * )
69
+ * }
70
+ * ```
71
+ */
72
+ export declare function usePersist(): PersistApi;
73
+ /**
74
+ * API returned by usePersistEntity hook
75
+ */
76
+ export interface EntityPersistApi {
77
+ /** Persist this entity */
78
+ persist(options?: BatchPersistOptions): Promise<EntityPersistResult>;
79
+ /** Persist specific fields of this entity */
80
+ persistFields(fields: readonly string[], options?: BatchPersistOptions): Promise<EntityPersistResult>;
81
+ /** Check if this entity is currently being persisted */
82
+ isPersisting: boolean;
83
+ /** Check if this entity has any dirty changes */
84
+ isDirty: boolean;
85
+ /** Get dirty fields for this entity */
86
+ dirtyFields: readonly string[];
87
+ /** Get dirty relations for this entity */
88
+ dirtyRelations: readonly string[];
89
+ }
90
+ /**
91
+ * Hook for accessing persistence API for a specific entity.
92
+ * Provides convenience methods scoped to a single entity.
93
+ *
94
+ * @example
95
+ * ```tsx
96
+ * function ArticleEditor({ id }: { id: string }) {
97
+ * const article = useEntity('Article', { id })
98
+ * const { persist, persistFields, isPersisting, isDirty } = usePersistEntity('Article', id)
99
+ *
100
+ * return (
101
+ * <div>
102
+ * <input {...article.fields.title.inputProps} />
103
+ * <button onClick={() => persistFields(['title'])} disabled={isPersisting}>
104
+ * Save Title
105
+ * </button>
106
+ * <button onClick={() => persist()} disabled={isPersisting || !isDirty}>
107
+ * Save All
108
+ * </button>
109
+ * </div>
110
+ * )
111
+ * }
112
+ * ```
113
+ */
114
+ export declare function usePersistEntity(entityType: string, entityId: string): EntityPersistApi;
115
+ //# sourceMappingURL=usePersist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePersist.d.ts","sourceRoot":"","sources":["../../src/hooks/usePersist.ts"],"names":[],"mappings":"AACA,OAAO,EACN,cAAc,EAEd,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EAIxB,KAAK,YAAY,EACjB,MAAM,kBAAkB,CAAA;AAGzB;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAAE,QAAQ,CAAC,CAAC,cAAc,CAAC,EAAE,YAAY,CAAA;CAAE,CAAA;AASxE;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,kDAAkD;IAClD,UAAU,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC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