@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,40 @@
1
+ import { GraphQlClient } from '@contember/graphql-client';
2
+ import { ContentClient, ContentQueryBuilder, SchemaNames } from '@contember/client-content';
3
+ import type { BackendAdapter, Query, QueryResult, QueryOptions, PersistResult, CreateResult, DeleteResult } from './types.js';
4
+ /**
5
+ * Options for ContemberAdapter
6
+ */
7
+ export interface ContemberAdapterOptions {
8
+ /** GraphQL client instance */
9
+ client: GraphQlClient;
10
+ /** Contember schema names for query building */
11
+ schema: SchemaNames;
12
+ }
13
+ /**
14
+ * Backend adapter for Contember Content API.
15
+ * Uses @contember/client-content for type-safe GraphQL operations.
16
+ */
17
+ export declare class ContemberAdapter implements BackendAdapter {
18
+ private readonly contentClient;
19
+ private readonly queryBuilder;
20
+ constructor(contentClient: ContentClient, queryBuilder: ContentQueryBuilder);
21
+ query(queries: readonly Query[], options?: QueryOptions): Promise<QueryResult[]>;
22
+ private buildGetQuery;
23
+ private buildListQuery;
24
+ persist(entityType: string, id: string, changes: Record<string, unknown>): Promise<PersistResult>;
25
+ create(entityType: string, data: Record<string, unknown>): Promise<CreateResult>;
26
+ delete(entityType: string, id: string): Promise<DeleteResult>;
27
+ /**
28
+ * Converts Contember mutation result to our ContemberMutationResult type.
29
+ */
30
+ private toMutationResult;
31
+ /**
32
+ * Builds ContentEntitySelection from QuerySpec
33
+ */
34
+ private buildEntitySelection;
35
+ /**
36
+ * Recursively applies QueryFieldSpec[] to ContentEntitySelection
37
+ */
38
+ private applyFieldsToSelection;
39
+ }
40
+ //# sourceMappingURL=ContemberAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContemberAdapter.d.ts","sourceRoot":"","sources":["../../src/adapter/ContemberAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM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, QueryResult, QueryOptions, PersistResult, CreateResult, DeleteResult } from './types.js';
2
+ /**
3
+ * In-memory data store structure
4
+ */
5
+ export type MockDataStore = {
6
+ [entityType: string]: {
7
+ [id: string]: Record<string, unknown>;
8
+ };
9
+ };
10
+ /**
11
+ * Options for MockAdapter
12
+ */
13
+ export interface MockAdapterOptions {
14
+ /** Simulated network delay in milliseconds (default: 100) */
15
+ delay?: number;
16
+ /** Whether to log operations to console (default: false) */
17
+ debug?: boolean;
18
+ }
19
+ /**
20
+ * Mock backend adapter for testing and development.
21
+ * Stores data in memory and simulates async operations.
22
+ */
23
+ export declare class MockAdapter implements BackendAdapter {
24
+ private store;
25
+ private readonly delay;
26
+ private readonly debug;
27
+ private readonly queryEngine;
28
+ constructor(store: MockDataStore, options?: MockAdapterOptions);
29
+ /**
30
+ * Simulates network delay with abort support
31
+ */
32
+ private simulateDelay;
33
+ /**
34
+ * Logs operations if debug is enabled
35
+ */
36
+ private log;
37
+ query(queries: readonly Query[], options?: QueryOptions): Promise<QueryResult[]>;
38
+ private executeGet;
39
+ private executeList;
40
+ persist(entityType: string, id: string, changes: Record<string, unknown>): Promise<PersistResult>;
41
+ /**
42
+ * Applies changes to an entity, handling Contember-style relation operations.
43
+ * Supports:
44
+ * - Scalar fields: direct assignment
45
+ * - HasOne: { connect: { id } }, { disconnect: true }, { delete: true }, { create: {...} }, { update: {...} }
46
+ * - HasMany: [{ connect: { id } }, { disconnect: { id } }, { delete: { id } }, { create: {...} }, { update: { by: { id }, data: {...} } }]
47
+ */
48
+ private applyChanges;
49
+ /**
50
+ * Applies hasMany relation operations.
51
+ */
52
+ private applyHasManyOperations;
53
+ /**
54
+ * Resolves a related entity by ID from any entity store.
55
+ * Returns a copy of the entity data or { id } if not found.
56
+ */
57
+ private resolveRelatedEntity;
58
+ /**
59
+ * Creates a related entity with a generated ID.
60
+ */
61
+ private createRelatedEntity;
62
+ /**
63
+ * Deletes a related entity from any entity store.
64
+ */
65
+ private deleteRelatedEntity;
66
+ create(entityType: string, data: Record<string, unknown>): Promise<CreateResult>;
67
+ delete(entityType: string, id: string): Promise<DeleteResult>;
68
+ /**
69
+ * Generates a simple unique ID
70
+ */
71
+ private generateId;
72
+ /**
73
+ * Gets the current store state (for testing/debugging)
74
+ */
75
+ getStore(): MockDataStore;
76
+ /**
77
+ * Resets the store to initial state
78
+ */
79
+ resetStore(newStore: MockDataStore): void;
80
+ }
81
+ //# sourceMappingURL=MockAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MockAdapter.d.ts","sourceRoot":"","sources":["../../src/adapter/MockAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAuB,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAGlJ;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B,CAAC,UAAU,EAAE,MAAM,GAAG;QACrB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KACrC,CAAA;CACD,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,6DAA6D;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,4DAA4D;IAC5D,KAAK,CAAC,EAAE,OAAO,CAAA;CACf;AAED;;;GAGG;AACH,qBAAa,WAAY,YAAW,cAAc;IAMhD,OAAO,CAAC,KAAK;IALd,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAiB;gBAGpC,KAAK,EAAE,aAAa,EAC5B,OAAO,GAAE,kBAAuB;IAOjC;;OAEG;YACW,aAAa;IA0B3B;;OAEG;IACH,OAAO,CAAC,GAAG;IAML,KAAK,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAatF,OAAO,CAAC,UAAU;IAiClB,OAAO,CAAC,WAAW;IA2Bb,OAAO,CACZ,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,aAAa,CAAC;IA2BzB;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IAuDpB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA0D9B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAK3B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IASrB,MAAM,CACX,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,OAAO,CAAC,YAAY,CAAC;IAmBlB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAYnE;;OAEG;IACH,OAAO,CAAC,UAAU;IAIlB;;OAEG;IACH,QAAQ,IAAI,aAAa;IAIzB;;OAEG;IACH,UAAU,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;CAGzC"}
@@ -0,0 +1,43 @@
1
+ import type { QueryFieldSpec } from '../selection/buildQuery.js';
2
+ /**
3
+ * MockQueryEngine provides in-memory query operations for MockAdapter.
4
+ * Extracted for better testability and separation of concerns.
5
+ *
6
+ * Supports:
7
+ * - Filtering with various operators (eq, notEq, in, lt, gt, contains, etc.)
8
+ * - Ordering with multi-field support and null handling
9
+ * - Pagination (offset/limit)
10
+ * - Field projection with nested relation support
11
+ */
12
+ export declare class MockQueryEngine {
13
+ /**
14
+ * Filters entities based on a filter object.
15
+ */
16
+ filter(entities: Record<string, unknown>[], filter: Record<string, unknown>): Record<string, unknown>[];
17
+ /**
18
+ * Orders entities based on orderBy specifications.
19
+ */
20
+ orderBy(entities: Record<string, unknown>[], orderBy: readonly Record<string, unknown>[]): Record<string, unknown>[];
21
+ /**
22
+ * Paginates entities using offset and limit.
23
+ */
24
+ paginate(entities: Record<string, unknown>[], offset?: number, limit?: number): Record<string, unknown>[];
25
+ /**
26
+ * Projects only the requested fields from source data.
27
+ * Supports nested relations (hasOne and hasMany).
28
+ */
29
+ projectFields(source: Record<string, unknown>, fields: QueryFieldSpec[], basePath?: string[]): Record<string, unknown>;
30
+ /**
31
+ * Checks if an entity matches a filter.
32
+ */
33
+ private matchesFilter;
34
+ /**
35
+ * Checks if a value matches a condition object.
36
+ */
37
+ private matchesCondition;
38
+ /**
39
+ * Gets a nested value from an object using a path.
40
+ */
41
+ private getNestedValue;
42
+ }
43
+ //# sourceMappingURL=MockQueryEngine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MockQueryEngine.d.ts","sourceRoot":"","sources":["../../src/adapter/MockQueryEngine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAEhE;;;;;;;;;GASG;AACH,qBAAa,eAAe;IAC3B;;OAEG;IACH,MAAM,CACL,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;IAI5B;;OAEG;IACH,OAAO,CACN,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EACnC,OAAO,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GACzC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;IA0B5B;;OAEG;IACH,QAAQ,CACP,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EACnC,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,GACZ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;IAW5B;;;OAGG;IACH,aAAa,CACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,EAAE,cAAc,EAAE,EACxB,QAAQ,GAAE,MAAM,EAAO,GACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAgD1B;;OAEG;IACH,OAAO,CAAC,aAAa;IAqCrB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAgDxB;;OAEG;IACH,OAAO,CAAC,cAAc;CAYtB"}
@@ -0,0 +1,5 @@
1
+ export type { BackendAdapter, QueryOptions, Query, GetQuery, ListQuery, QueryResult, GetQueryResult, ListQueryResult, PersistResult, CreateResult, DeleteResult, EntityUniqueWhere, UniqueWhereValue, TransactionMutation, TransactionMutationResult, TransactionResult, } from './types.js';
2
+ export { MockAdapter, type MockDataStore, type MockAdapterOptions } from './MockAdapter.js';
3
+ export { MockQueryEngine } from './MockQueryEngine.js';
4
+ export { ContemberAdapter, type ContemberAdapterOptions } from './ContemberAdapter.js';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapter/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,cAAc,EACd,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,SAAS,EACT,WAAW,EACX,cAAc,EACd,eAAe,EACf,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,GACjB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,WAAW,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAA"}
@@ -0,0 +1,184 @@
1
+ import type { QuerySpec } from '../selection/buildQuery.js';
2
+ import type { EntityWhere, EntityOrderBy } from '../selection/queryTypes.js';
3
+ import type { ContemberMutationResult } from '../errors/pathMapper.js';
4
+ /**
5
+ * Options for query operations
6
+ */
7
+ export interface QueryOptions {
8
+ /**
9
+ * AbortSignal for cancelling the request
10
+ */
11
+ readonly signal?: AbortSignal;
12
+ }
13
+ /**
14
+ * Recursive value type for unique where fields (string or number identifiers).
15
+ * Structurally compatible with Input.UniqueWhere from @contember/schema.
16
+ */
17
+ export type UniqueWhereValue = string | number | {
18
+ readonly [field: string]: UniqueWhereValue;
19
+ };
20
+ /**
21
+ * Unique field lookup for single entity queries.
22
+ * Supports id and any other unique field.
23
+ */
24
+ export type EntityUniqueWhere = {
25
+ readonly [field: string]: UniqueWhereValue;
26
+ };
27
+ /**
28
+ * Query for a single entity by unique field(s)
29
+ */
30
+ export interface GetQuery {
31
+ readonly type: 'get';
32
+ readonly entityType: string;
33
+ readonly by: EntityUniqueWhere;
34
+ readonly spec: QuerySpec;
35
+ }
36
+ /**
37
+ * Query for a list of entities
38
+ */
39
+ export interface ListQuery<TEntity = unknown> {
40
+ readonly type: 'list';
41
+ readonly entityType: string;
42
+ readonly filter?: EntityWhere<TEntity>;
43
+ readonly orderBy?: readonly EntityOrderBy<TEntity>[];
44
+ readonly limit?: number;
45
+ readonly offset?: number;
46
+ readonly spec: QuerySpec;
47
+ }
48
+ /**
49
+ * Union of all query types
50
+ */
51
+ export type Query<TEntity = unknown> = GetQuery | ListQuery<TEntity>;
52
+ /**
53
+ * Result for a single get query
54
+ */
55
+ export interface GetQueryResult {
56
+ readonly type: 'get';
57
+ readonly data: Record<string, unknown> | null;
58
+ }
59
+ /**
60
+ * Result for a list query
61
+ */
62
+ export interface ListQueryResult {
63
+ readonly type: 'list';
64
+ readonly data: readonly Record<string, unknown>[];
65
+ }
66
+ /**
67
+ * Union of query results
68
+ */
69
+ export type QueryResult = GetQueryResult | ListQueryResult;
70
+ /**
71
+ * Result of a persist operation.
72
+ * Contains detailed error information for error mapping.
73
+ */
74
+ export interface PersistResult {
75
+ readonly ok: boolean;
76
+ readonly errorMessage?: string;
77
+ /** Detailed mutation result for error mapping (Contember-specific) */
78
+ readonly mutationResult?: ContemberMutationResult;
79
+ }
80
+ /**
81
+ * Result of a create operation.
82
+ * Contains the created entity data or error information.
83
+ */
84
+ export interface CreateResult {
85
+ readonly ok: boolean;
86
+ readonly errorMessage?: string;
87
+ /** The created entity data (when ok is true) */
88
+ readonly data?: Record<string, unknown>;
89
+ /** Detailed mutation result for error mapping (Contember-specific) */
90
+ readonly mutationResult?: ContemberMutationResult;
91
+ }
92
+ /**
93
+ * Result of a delete operation.
94
+ */
95
+ export interface DeleteResult {
96
+ readonly ok: boolean;
97
+ readonly errorMessage?: string;
98
+ /** Detailed mutation result for error mapping (Contember-specific) */
99
+ readonly mutationResult?: ContemberMutationResult;
100
+ }
101
+ /**
102
+ * A single mutation in a transaction.
103
+ */
104
+ export interface TransactionMutation {
105
+ readonly entityType: string;
106
+ readonly entityId: string;
107
+ readonly operation: 'create' | 'update' | 'delete';
108
+ readonly data?: Record<string, unknown>;
109
+ }
110
+ /**
111
+ * Result of a single mutation in a transaction.
112
+ */
113
+ export interface TransactionMutationResult {
114
+ readonly entityType: string;
115
+ readonly entityId: string;
116
+ readonly ok: boolean;
117
+ /** Server-assigned ID for creates */
118
+ readonly persistedId?: string;
119
+ readonly errorMessage?: string;
120
+ readonly mutationResult?: ContemberMutationResult;
121
+ }
122
+ /**
123
+ * Result of a transaction persist operation.
124
+ * All-or-nothing: if any mutation fails, all are rolled back.
125
+ */
126
+ export interface TransactionResult {
127
+ /** Whether all mutations succeeded */
128
+ readonly ok: boolean;
129
+ /** Results per mutation, in same order as input */
130
+ readonly results: readonly TransactionMutationResult[];
131
+ }
132
+ /**
133
+ * Interface for backend adapters.
134
+ * Implement this to connect bindx to your data source.
135
+ */
136
+ export interface BackendAdapter {
137
+ /**
138
+ * Execute one or more queries in a single request.
139
+ * When multiple queries are provided, the adapter should batch them
140
+ * into a single network request where possible.
141
+ *
142
+ * @param queries - Array of queries to execute
143
+ * @param options - Optional query options including AbortSignal
144
+ * @returns Array of results in the same order as queries
145
+ */
146
+ query(queries: readonly Query[], options?: QueryOptions): Promise<QueryResult[]>;
147
+ /**
148
+ * Persists changes to an entity.
149
+ * Returns a result object with success/failure status and error details.
150
+ *
151
+ * @param entityType - The type/name of the entity
152
+ * @param id - The entity's unique identifier
153
+ * @param changes - The changed fields to persist
154
+ * @returns Result with ok status and optional error details
155
+ */
156
+ persist(entityType: string, id: string, changes: Record<string, unknown>): Promise<PersistResult>;
157
+ /**
158
+ * Creates a new entity.
159
+ * Returns a result object with the created entity or error details.
160
+ *
161
+ * @param entityType - The type/name of the entity
162
+ * @param data - The initial data for the entity
163
+ * @returns Result with ok status, created entity data, and optional error details
164
+ */
165
+ create?(entityType: string, data: Record<string, unknown>): Promise<CreateResult>;
166
+ /**
167
+ * Deletes an entity.
168
+ * Returns a result object with success/failure status.
169
+ *
170
+ * @param entityType - The type/name of the entity
171
+ * @param id - The entity's unique identifier
172
+ * @returns Result with ok status and optional error details
173
+ */
174
+ delete?(entityType: string, id: string): Promise<DeleteResult>;
175
+ /**
176
+ * Persists multiple mutations in a single transaction.
177
+ * All-or-nothing: if any mutation fails, all are rolled back.
178
+ *
179
+ * @param mutations - Array of mutations to execute
180
+ * @returns Result with success status and per-mutation results
181
+ */
182
+ persistTransaction?(mutations: readonly TransactionMutation[]): Promise<TransactionResult>;
183
+ }
184
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/adapter/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC5E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OAAO,CAAC,YAAY,CAAC,CAAA;IAE9D;;;;;;OAMG;IACH,kBAAkB,CAAC,CAAC,SAAS,EAAE,SAAS,mBAAmB,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;CAC1F"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * ComponentBrand provides unique identity for each component created with createComponent.
3
+ * Each instance has a unique runtime Symbol for brand validation.
4
+ * The class structure itself provides nominal typing in TypeScript.
5
+ */
6
+ export declare class ComponentBrand {
7
+ readonly name: string;
8
+ /**
9
+ * Private property to ensure nominal typing.
10
+ * Each class instance is considered a unique type.
11
+ */
12
+ private readonly __nominal;
13
+ /**
14
+ * Runtime symbol for brand validation.
15
+ * Used to check that EntityRef includes required component brands.
16
+ */
17
+ readonly brandSymbol: symbol;
18
+ constructor(name: string);
19
+ }
20
+ /**
21
+ * Type alias for any ComponentBrand.
22
+ * Used as default/base type in generic constraints.
23
+ */
24
+ export type AnyBrand = ComponentBrand;
25
+ //# sourceMappingURL=ComponentBrand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComponentBrand.d.ts","sourceRoot":"","sources":["../../src/brand/ComponentBrand.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,cAAc;aAaE,IAAI,EAAE,MAAM;IAZxC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAO;IAEjC;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;gBAEA,IAAI,EAAE,MAAM;CAGxC;AAED;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,cAAc,CAAA"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Contember-specific utilities for bindx
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export { MutationCollector, type EntityMutationResult } from '../persistence/MutationCollector.js';
7
+ export { ContemberSchemaMutationAdapter } from '../persistence/ContemberSchemaMutationAdapter.js';
8
+ export type { MutationSchemaProvider } from '../persistence/MutationSchemaProvider.js';
9
+ export type { SchemaNames, SchemaEntityNames, ContentClientInput, } from '@contember/client-content';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contember/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,iBAAiB,EAAE,KAAK,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAClG,OAAO,EAAE,8BAA8B,EAAE,MAAM,kDAAkD,CAAA;AACjG,YAAY,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAA;AAGtF,YAAY,EACX,WAAW,EACX,iBAAiB,EACjB,kBAAkB,GAClB,MAAM,2BAA2B,CAAA"}
@@ -0,0 +1,64 @@
1
+ import type { SnapshotStore } from '../store/SnapshotStore.js';
2
+ import type { Action } from './actions.js';
3
+ import { EventEmitter } from '../events/EventEmitter.js';
4
+ /**
5
+ * ActionDispatcher centralizes all state mutations.
6
+ * All changes to the store go through this dispatcher.
7
+ *
8
+ * Benefits:
9
+ * - Single point of control for all mutations
10
+ * - Easy to add logging, debugging, middleware
11
+ * - Ensures consistent state updates
12
+ * - Enables action replay/undo if needed
13
+ * - Event system for subscriptions and interceptors
14
+ */
15
+ export declare class ActionDispatcher {
16
+ private readonly store;
17
+ private readonly middlewares;
18
+ private readonly eventEmitter;
19
+ constructor(store: SnapshotStore, eventEmitter?: EventEmitter);
20
+ /**
21
+ * Gets the event emitter for external access.
22
+ */
23
+ getEventEmitter(): EventEmitter;
24
+ /**
25
+ * Dispatches an action to update the store.
26
+ * Runs synchronous interceptors (before-events) and emits after-events.
27
+ * Async interceptors are skipped with a warning — use dispatchAsync() for those.
28
+ */
29
+ dispatch(action: Action): void;
30
+ /**
31
+ * Dispatches an action with full interceptor support.
32
+ * Returns true if the action was executed, false if it was cancelled by an interceptor.
33
+ */
34
+ dispatchAsync(action: Action): Promise<boolean>;
35
+ /**
36
+ * Updates an action based on a modified before event.
37
+ * Used when an interceptor modifies the event.
38
+ */
39
+ private updateActionFromEvent;
40
+ /**
41
+ * Adds a middleware to the dispatcher.
42
+ * Middlewares are called in order before action execution.
43
+ */
44
+ addMiddleware(middleware: ActionMiddleware): void;
45
+ /**
46
+ * Removes a middleware from the dispatcher.
47
+ */
48
+ removeMiddleware(middleware: ActionMiddleware): void;
49
+ /**
50
+ * Executes an action, updating the store.
51
+ */
52
+ private execute;
53
+ }
54
+ /**
55
+ * Middleware function type.
56
+ * Can inspect/modify actions before execution.
57
+ * Return false to cancel the action.
58
+ */
59
+ export type ActionMiddleware = (action: Action, store: SnapshotStore) => boolean | void;
60
+ /**
61
+ * Creates a logging middleware for debugging.
62
+ */
63
+ export declare function createLoggingMiddleware(prefix?: string): ActionMiddleware;
64
+ //# sourceMappingURL=ActionDispatcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionDispatcher.d.ts","sourceRoot":"","sources":["../../src/core/ActionDispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAOxD;;;;;;;;;;GAUG;AACH,qBAAa,gBAAgB;IAK3B,OAAO,CAAC,QAAQ,CAAC,KAAK;IAJvB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyB;IACrD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAc;gBAGzB,KAAK,EAAE,aAAa,EACrC,YAAY,CAAC,EAAE,YAAY;IAK5B;;OAEG;IACH,eAAe,IAAI,YAAY;IAI/B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAqC9B;;;OAGG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAsCrD;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IA4B7B;;;OAGG;IACH,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI;IAIjD;;OAEG;IACH,gBAAgB,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI;IAOpD;;OAEG;IACH,OAAO,CAAC,OAAO;CA8Nf;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,KAAK,OAAO,GAAG,IAAI,CAAA;AAEvF;;GAEG;AACH,wBAAgB,uBAAuB,CACtC,MAAM,GAAE,MAAkB,GACxB,gBAAgB,CAIlB"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Disposable pattern for cleanup management.
3
+ * Ensures proper cleanup of subscriptions and resources.
4
+ */
5
+ /**
6
+ * Interface for objects that can be disposed.
7
+ */
8
+ export interface Disposable {
9
+ dispose(): void;
10
+ }
11
+ /**
12
+ * A group of disposables that can be disposed together.
13
+ * Provides safe cleanup even if individual dispose() calls throw.
14
+ */
15
+ export declare class DisposableGroup implements Disposable {
16
+ private disposables;
17
+ private disposed;
18
+ /**
19
+ * Adds a disposable to the group.
20
+ * If the group is already disposed, the disposable is disposed immediately.
21
+ */
22
+ add(disposable: Disposable): void;
23
+ /**
24
+ * Adds a callback as a disposable.
25
+ */
26
+ addCallback(callback: () => void): void;
27
+ /**
28
+ * Adds an unsubscribe function as a disposable.
29
+ */
30
+ addUnsubscribe(unsubscribe: () => void): void;
31
+ /**
32
+ * Disposes all items in the group.
33
+ * Each item is disposed even if previous ones throw.
34
+ */
35
+ dispose(): void;
36
+ /**
37
+ * Checks if the group has been disposed.
38
+ */
39
+ isDisposed(): boolean;
40
+ /**
41
+ * Gets the number of disposables in the group.
42
+ */
43
+ get size(): number;
44
+ }
45
+ /**
46
+ * Creates a disposable from a callback function.
47
+ */
48
+ export declare function createDisposable(callback: () => void): Disposable;
49
+ /**
50
+ * Combines multiple disposables into one.
51
+ */
52
+ export declare function combineDisposables(...disposables: Disposable[]): Disposable;
53
+ /**
54
+ * Type guard to check if something is disposable.
55
+ */
56
+ export declare function isDisposable(value: unknown): value is Disposable;
57
+ //# sourceMappingURL=Disposable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Disposable.d.ts","sourceRoot":"","sources":["../../src/core/Disposable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,OAAO,IAAI,IAAI,CAAA;CACf;AAED;;;GAGG;AACH,qBAAa,eAAgB,YAAW,UAAU;IACjD,OAAO,CAAC,WAAW,CAAmB;IACtC,OAAO,CAAC,QAAQ,CAAQ;IAExB;;;OAGG;IACH,GAAG,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI;IAajC;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAIvC;;OAEG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,IAAI,GAAG,IAAI;IAI7C;;;OAGG;IACH,OAAO,IAAI,IAAI;IAqBf;;OAEG;IACH,UAAU,IAAI,OAAO;IAIrB;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;CACD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,UAAU,CASjE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,WAAW,EAAE,UAAU,EAAE,GAAG,UAAU,CAM3E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAMhE"}
@@ -0,0 +1,80 @@
1
+ import type { BackendAdapter } from '../adapter/types.js';
2
+ import type { SnapshotStore } from '../store/SnapshotStore.js';
3
+ import type { QuerySpec } from '../selection/buildQuery.js';
4
+ import type { EntityWhere, EntityOrderBy } from '../selection/queryTypes.js';
5
+ import { type FieldError } from '../errors/types.js';
6
+ /**
7
+ * Result of entity loading operation
8
+ */
9
+ export type EntityLoadResult<T> = {
10
+ status: 'success';
11
+ data: T;
12
+ } | {
13
+ status: 'error';
14
+ error: FieldError;
15
+ } | {
16
+ status: 'not_found';
17
+ };
18
+ /**
19
+ * Result of entity list loading operation
20
+ */
21
+ export type EntityListLoadResult<T> = {
22
+ status: 'success';
23
+ data: T[];
24
+ } | {
25
+ status: 'error';
26
+ error: FieldError;
27
+ };
28
+ /**
29
+ * Options for loading a single entity
30
+ */
31
+ export interface LoadEntityOptions {
32
+ entityType: string;
33
+ id: string;
34
+ query: QuerySpec;
35
+ useCache?: boolean;
36
+ signal?: AbortSignal;
37
+ }
38
+ /**
39
+ * Options for loading entity list
40
+ */
41
+ export interface LoadEntityListOptions<TEntity = unknown> {
42
+ entityType: string;
43
+ query: QuerySpec;
44
+ filter?: EntityWhere<TEntity>;
45
+ orderBy?: readonly EntityOrderBy<TEntity>[];
46
+ limit?: number;
47
+ offset?: number;
48
+ signal?: AbortSignal;
49
+ }
50
+ /**
51
+ * Non-React service for loading entities.
52
+ * Can be used in any JavaScript environment.
53
+ */
54
+ export declare class EntityLoader {
55
+ private readonly adapter;
56
+ private readonly store;
57
+ constructor(adapter: BackendAdapter, store: SnapshotStore);
58
+ /**
59
+ * Loads a single entity by ID.
60
+ */
61
+ loadOne<T>(options: LoadEntityOptions): Promise<EntityLoadResult<T>>;
62
+ /**
63
+ * Loads multiple entities matching filter.
64
+ */
65
+ loadMany<T, TEntity = unknown>(options: LoadEntityListOptions<TEntity>): Promise<EntityListLoadResult<T>>;
66
+ /**
67
+ * Checks if entity exists in cache.
68
+ */
69
+ hasInCache(entityType: string, id: string): boolean;
70
+ /**
71
+ * Gets entity from cache if available.
72
+ */
73
+ getFromCache<T>(entityType: string, id: string): T | null;
74
+ }
75
+ /**
76
+ * Creates an EntityLoader instance.
77
+ * Factory function for easier testing and dependency injection.
78
+ */
79
+ export declare function createEntityLoader(adapter: BackendAdapter, store: SnapshotStore): EntityLoader;
80
+ //# sourceMappingURL=EntityLoader.d.ts.map
@@ -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