@sincpro/mobile 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 (232) hide show
  1. package/README.md +74 -0
  2. package/dist/adapters/Bluetooth.adapter.d.ts +14 -0
  3. package/dist/adapters/Bluetooth.adapter.js +100 -0
  4. package/dist/adapters/Geo.adapter.d.ts +8 -0
  5. package/dist/adapters/Geo.adapter.js +30 -0
  6. package/dist/adapters/JsonSerializer.adapter.d.ts +28 -0
  7. package/dist/adapters/JsonSerializer.adapter.js +47 -0
  8. package/dist/adapters/Network.adapter.d.ts +4 -0
  9. package/dist/adapters/Network.adapter.js +13 -0
  10. package/dist/adapters/ReceiptExporter.adapter.d.ts +19 -0
  11. package/dist/adapters/ReceiptExporter.adapter.js +142 -0
  12. package/dist/adapters/repositories/database_table.repository.d.ts +13 -0
  13. package/dist/adapters/repositories/database_table.repository.js +29 -0
  14. package/dist/adapters/repositories/domain_event.repository.d.ts +32 -0
  15. package/dist/adapters/repositories/domain_event.repository.js +147 -0
  16. package/dist/adapters/repositories/domain_event_dead_letter.repository.d.ts +23 -0
  17. package/dist/adapters/repositories/domain_event_dead_letter.repository.js +81 -0
  18. package/dist/adapters/repositories/setting.repository.d.ts +10 -0
  19. package/dist/adapters/repositories/setting.repository.js +21 -0
  20. package/dist/adapters/webview.adapter.d.ts +10 -0
  21. package/dist/adapters/webview.adapter.js +166 -0
  22. package/dist/domain/connectivity/bluetooth.d.ts +19 -0
  23. package/dist/domain/connectivity/bluetooth.js +1 -0
  24. package/dist/domain/connectivity/events.d.ts +17 -0
  25. package/dist/domain/connectivity/events.js +17 -0
  26. package/dist/domain/connectivity/geo.d.ts +4 -0
  27. package/dist/domain/connectivity/geo.js +1 -0
  28. package/dist/domain/connectivity/index.d.ts +3 -0
  29. package/dist/domain/connectivity/index.js +3 -0
  30. package/dist/domain/connectivity/network.d.ts +7 -0
  31. package/dist/domain/connectivity/network.js +1 -0
  32. package/dist/domain/database/database.d.ts +16 -0
  33. package/dist/domain/database/database.js +1 -0
  34. package/dist/domain/database/index.d.ts +2 -0
  35. package/dist/domain/database/index.js +2 -0
  36. package/dist/domain/database/repository.d.ts +19 -0
  37. package/dist/domain/database/repository.js +1 -0
  38. package/dist/domain/entity/entity.d.ts +109 -0
  39. package/dist/domain/entity/entity.js +246 -0
  40. package/dist/domain/entity/entity_collection.d.ts +396 -0
  41. package/dist/domain/entity/entity_collection.js +824 -0
  42. package/dist/domain/entity/index.d.ts +3 -0
  43. package/dist/domain/entity/index.js +3 -0
  44. package/dist/domain/entity/value_object.d.ts +12 -0
  45. package/dist/domain/entity/value_object.js +39 -0
  46. package/dist/domain/event_sourcing/domain_event.d.ts +58 -0
  47. package/dist/domain/event_sourcing/domain_event.js +164 -0
  48. package/dist/domain/event_sourcing/event.d.ts +25 -0
  49. package/dist/domain/event_sourcing/event.js +25 -0
  50. package/dist/domain/event_sourcing/event_handler.d.ts +7 -0
  51. package/dist/domain/event_sourcing/event_handler.js +13 -0
  52. package/dist/domain/event_sourcing/index.d.ts +2 -0
  53. package/dist/domain/event_sourcing/index.js +2 -0
  54. package/dist/domain/events.d.ts +33 -0
  55. package/dist/domain/events.js +32 -0
  56. package/dist/domain/icon.d.ts +1 -0
  57. package/dist/domain/icon.js +1 -0
  58. package/dist/domain/index.d.ts +9 -0
  59. package/dist/domain/index.js +9 -0
  60. package/dist/domain/print/driver_registry.d.ts +4 -0
  61. package/dist/domain/print/driver_registry.js +29 -0
  62. package/dist/domain/print/events.d.ts +13 -0
  63. package/dist/domain/print/events.js +13 -0
  64. package/dist/domain/print/index.d.ts +2 -0
  65. package/dist/domain/print/index.js +1 -0
  66. package/dist/domain/print/printer.d.ts +35 -0
  67. package/dist/domain/print/printer.js +1 -0
  68. package/dist/domain/receipt.d.ts +31 -0
  69. package/dist/domain/receipt.js +1 -0
  70. package/dist/domain/repositories.d.ts +6 -0
  71. package/dist/domain/repositories.js +7 -0
  72. package/dist/domain/settings.d.ts +7 -0
  73. package/dist/domain/settings.js +1 -0
  74. package/dist/domain/webview/events.d.ts +11 -0
  75. package/dist/domain/webview/events.js +11 -0
  76. package/dist/domain/webview/index.d.ts +1 -0
  77. package/dist/domain/webview/index.js +1 -0
  78. package/dist/domain/webview/webview.d.ts +57 -0
  79. package/dist/domain/webview/webview.js +9 -0
  80. package/dist/entrypoints/cron/Cron.d.ts +13 -0
  81. package/dist/entrypoints/cron/Cron.js +57 -0
  82. package/dist/entrypoints/cron/checkNetworkStatus.cron.d.ts +3 -0
  83. package/dist/entrypoints/cron/checkNetworkStatus.cron.js +10 -0
  84. package/dist/entrypoints/db/index.d.ts +2 -0
  85. package/dist/entrypoints/db/index.js +2 -0
  86. package/dist/entrypoints/db/migrations.d.ts +10 -0
  87. package/dist/entrypoints/db/migrations.js +115 -0
  88. package/dist/entrypoints/db/repositories.d.ts +8 -0
  89. package/dist/entrypoints/db/repositories.js +34 -0
  90. package/dist/entrypoints/queue/QueueProcessor.d.ts +12 -0
  91. package/dist/entrypoints/queue/QueueProcessor.js +75 -0
  92. package/dist/entrypoints/queue/activateDomain.subscriber.d.ts +7 -0
  93. package/dist/entrypoints/queue/activateDomain.subscriber.js +15 -0
  94. package/dist/entrypoints/queue/newAppSettings.handler.d.ts +7 -0
  95. package/dist/entrypoints/queue/newAppSettings.handler.js +17 -0
  96. package/dist/entrypoints/queue/printImage.subscriber.d.ts +7 -0
  97. package/dist/entrypoints/queue/printImage.subscriber.js +14 -0
  98. package/dist/entrypoints/queue/processWebViewMessage.subscriber.d.ts +7 -0
  99. package/dist/entrypoints/queue/processWebViewMessage.subscriber.js +23 -0
  100. package/dist/entrypoints/ui/AppShell.d.ts +15 -0
  101. package/dist/entrypoints/ui/AppShell.js +58 -0
  102. package/dist/entrypoints/ui/common_provider.d.ts +35 -0
  103. package/dist/entrypoints/ui/common_provider.js +244 -0
  104. package/dist/entrypoints/ui/domain_switcher.d.ts +19 -0
  105. package/dist/entrypoints/ui/domain_switcher.js +22 -0
  106. package/dist/entrypoints/ui/theme.d.ts +15 -0
  107. package/dist/entrypoints/ui/theme.js +16 -0
  108. package/dist/exceptions.d.ts +22 -0
  109. package/dist/exceptions.js +60 -0
  110. package/dist/framework/base_module.d.ts +14 -0
  111. package/dist/framework/base_module.js +40 -0
  112. package/dist/framework/createApp.d.ts +6 -0
  113. package/dist/framework/createApp.js +9 -0
  114. package/dist/framework/domain_module.d.ts +13 -0
  115. package/dist/framework/domain_module.js +18 -0
  116. package/dist/framework/kernel.d.ts +18 -0
  117. package/dist/framework/kernel.js +60 -0
  118. package/dist/framework/orchestrator.d.ts +29 -0
  119. package/dist/framework/orchestrator.js +118 -0
  120. package/dist/index.d.ts +16 -0
  121. package/dist/index.js +11 -0
  122. package/dist/infrastructure/database/connector.d.ts +13 -0
  123. package/dist/infrastructure/database/connector.js +165 -0
  124. package/dist/infrastructure/database/index.d.ts +2 -0
  125. package/dist/infrastructure/database/index.js +2 -0
  126. package/dist/infrastructure/database/mapped.d.ts +128 -0
  127. package/dist/infrastructure/database/mapped.js +174 -0
  128. package/dist/infrastructure/database/utils.d.ts +10 -0
  129. package/dist/infrastructure/database/utils.js +35 -0
  130. package/dist/infrastructure/logger.d.ts +45 -0
  131. package/dist/infrastructure/logger.js +125 -0
  132. package/dist/infrastructure/ui/ToastHost.d.ts +1 -0
  133. package/dist/infrastructure/ui/ToastHost.js +19 -0
  134. package/dist/infrastructure/ui/UIEventBus.d.ts +12 -0
  135. package/dist/infrastructure/ui/UIEventBus.js +65 -0
  136. package/dist/infrastructure/ui/errorHandler.d.ts +1 -0
  137. package/dist/infrastructure/ui/errorHandler.js +20 -0
  138. package/dist/infrastructure/ui/events.d.ts +1 -0
  139. package/dist/infrastructure/ui/events.js +1 -0
  140. package/dist/infrastructure/workers/CronWorker.d.ts +42 -0
  141. package/dist/infrastructure/workers/CronWorker.js +143 -0
  142. package/dist/infrastructure/workers/EventBus.d.ts +67 -0
  143. package/dist/infrastructure/workers/EventBus.js +279 -0
  144. package/dist/infrastructure/workers/index.d.ts +2 -0
  145. package/dist/infrastructure/workers/index.js +2 -0
  146. package/dist/services/bluetooth.service.d.ts +14 -0
  147. package/dist/services/bluetooth.service.js +72 -0
  148. package/dist/services/database_table.service.d.ts +8 -0
  149. package/dist/services/database_table.service.js +19 -0
  150. package/dist/services/dead_letter_queue.service.d.ts +38 -0
  151. package/dist/services/dead_letter_queue.service.js +99 -0
  152. package/dist/services/event.service.d.ts +7 -0
  153. package/dist/services/event.service.js +24 -0
  154. package/dist/services/network.service.d.ts +7 -0
  155. package/dist/services/network.service.js +43 -0
  156. package/dist/services/printer.service.d.ts +25 -0
  157. package/dist/services/printer.service.js +220 -0
  158. package/dist/services/webview.service.d.ts +17 -0
  159. package/dist/services/webview.service.js +59 -0
  160. package/dist/tools/utils/Initials.d.ts +1 -0
  161. package/dist/tools/utils/Initials.js +12 -0
  162. package/dist/tools/utils/collections.d.ts +120 -0
  163. package/dist/tools/utils/collections.js +158 -0
  164. package/dist/tools/utils/date.d.ts +70 -0
  165. package/dist/tools/utils/date.js +126 -0
  166. package/dist/tools/utils/maps.d.ts +4 -0
  167. package/dist/tools/utils/maps.js +20 -0
  168. package/dist/tools/utils/monetary.d.ts +3 -0
  169. package/dist/tools/utils/monetary.js +31 -0
  170. package/dist/tools/utils/quantity.d.ts +11 -0
  171. package/dist/tools/utils/quantity.js +44 -0
  172. package/dist/tools/utils/searchTools.d.ts +39 -0
  173. package/dist/tools/utils/searchTools.js +56 -0
  174. package/dist/tools/utils/serializer.d.ts +2 -0
  175. package/dist/tools/utils/serializer.js +44 -0
  176. package/dist/ui/components/atoms/DebugBanner.d.ts +2 -0
  177. package/dist/ui/components/atoms/DebugBanner.js +15 -0
  178. package/dist/ui/components/atoms/index.d.ts +1 -0
  179. package/dist/ui/components/atoms/index.js +1 -0
  180. package/dist/ui/components/molecules/BluetoothDeviceSelectorModal.d.ts +8 -0
  181. package/dist/ui/components/molecules/BluetoothDeviceSelectorModal.js +61 -0
  182. package/dist/ui/components/molecules/DeadLetterErrorBlock.d.ts +8 -0
  183. package/dist/ui/components/molecules/DeadLetterErrorBlock.js +14 -0
  184. package/dist/ui/components/molecules/EventTimelineItem.d.ts +7 -0
  185. package/dist/ui/components/molecules/EventTimelineItem.js +65 -0
  186. package/dist/ui/components/molecules/ProcessToast.d.ts +5 -0
  187. package/dist/ui/components/molecules/ProcessToast.js +51 -0
  188. package/dist/ui/components/molecules/ProcessToastProvider.d.ts +4 -0
  189. package/dist/ui/components/molecules/ProcessToastProvider.js +5 -0
  190. package/dist/ui/components/molecules/index.d.ts +5 -0
  191. package/dist/ui/components/molecules/index.js +5 -0
  192. package/dist/ui/components/organisms/BluetoothPrinterSelector.d.ts +7 -0
  193. package/dist/ui/components/organisms/BluetoothPrinterSelector.js +92 -0
  194. package/dist/ui/components/organisms/DatabaseInfoRow.d.ts +11 -0
  195. package/dist/ui/components/organisms/DatabaseInfoRow.js +8 -0
  196. package/dist/ui/components/organisms/DeadLetterQueueRow.d.ts +7 -0
  197. package/dist/ui/components/organisms/DeadLetterQueueRow.js +72 -0
  198. package/dist/ui/components/organisms/EventRow.d.ts +7 -0
  199. package/dist/ui/components/organisms/EventRow.js +90 -0
  200. package/dist/ui/components/organisms/InjectableWebView.d.ts +35 -0
  201. package/dist/ui/components/organisms/InjectableWebView.js +169 -0
  202. package/dist/ui/components/organisms/Receipt.d.ts +11 -0
  203. package/dist/ui/components/organisms/Receipt.js +207 -0
  204. package/dist/ui/components/organisms/TableInfoInfoRow.d.ts +9 -0
  205. package/dist/ui/components/organisms/TableInfoInfoRow.js +19 -0
  206. package/dist/ui/components/organisms/index.d.ts +7 -0
  207. package/dist/ui/components/organisms/index.js +7 -0
  208. package/dist/ui/index.d.ts +4 -0
  209. package/dist/ui/index.js +4 -0
  210. package/dist/ui/layouts/router_layouts.d.ts +17 -0
  211. package/dist/ui/layouts/router_layouts.js +20 -0
  212. package/dist/ui/screens/database/database.context.d.ts +32 -0
  213. package/dist/ui/screens/database/database.context.js +158 -0
  214. package/dist/ui/screens/database/database.json_detail.d.ts +2 -0
  215. package/dist/ui/screens/database/database.json_detail.js +19 -0
  216. package/dist/ui/screens/database/database.list.d.ts +1 -0
  217. package/dist/ui/screens/database/database.list.js +41 -0
  218. package/dist/ui/screens/database/database.table_rows.d.ts +2 -0
  219. package/dist/ui/screens/database/database.table_rows.js +10 -0
  220. package/dist/ui/screens/dead_letter_queue/dead_letter_queue.context.d.ts +34 -0
  221. package/dist/ui/screens/dead_letter_queue/dead_letter_queue.context.js +166 -0
  222. package/dist/ui/screens/dead_letter_queue/dead_letter_queue.list.d.ts +2 -0
  223. package/dist/ui/screens/dead_letter_queue/dead_letter_queue.list.js +24 -0
  224. package/dist/ui/screens/events/events.context.d.ts +25 -0
  225. package/dist/ui/screens/events/events.context.js +113 -0
  226. package/dist/ui/screens/events/events.list.d.ts +1 -0
  227. package/dist/ui/screens/events/events.list.js +26 -0
  228. package/dist/ui/screens/events/index.d.ts +1 -0
  229. package/dist/ui/screens/events/index.js +1 -0
  230. package/dist/ui/screens/index.d.ts +3 -0
  231. package/dist/ui/screens/index.js +3 -0
  232. package/package.json +125 -0
@@ -0,0 +1,396 @@
1
+ import { DomainEvent, type DomainEventClass } from "../../domain/event_sourcing/domain_event";
2
+ import { type Entity, type RemoteEntity } from "./entity";
3
+ import { ValueObject } from "./value_object";
4
+ export type CriteriaOperator = "=" | "!=" | "in" | "not_in" | "like" | ">" | "<" | ">=" | "<=";
5
+ export interface ICriteria<T = any> {
6
+ field: keyof T;
7
+ operator: CriteriaOperator;
8
+ value: any;
9
+ }
10
+ /**
11
+ * Type-safe, immutable collection for Entity aggregates with event sourcing support.
12
+ * Implements IEventSourced for domain event publishing and provides functional operations.
13
+ *
14
+ * @example
15
+ * const collection = new EntityCollection([priceList1, priceList2]);
16
+ *
17
+ * // Functional operations (immutable)
18
+ * const active = collection.filter(pl => pl.isActive).sortBy(pl => pl.name);
19
+ *
20
+ * // Aggregations
21
+ * const total = collection.sumBy(pl => pl.price);
22
+ * const cheapest = collection.minBy(pl => pl.price);
23
+ *
24
+ * // Set operations
25
+ * const union = collection1.union(collection2);
26
+ * const common = collection1.intersect(collection2);
27
+ *
28
+ * // Event sourcing
29
+ * await collection.publishEventWith(PRICE_LISTS_SYNCED, pl => ({ id: pl.remoteId, name: pl.name }));
30
+ */
31
+ export declare class EntityCollection<T extends Entity> extends ValueObject {
32
+ uuid: string;
33
+ eventIds: string[];
34
+ private entities;
35
+ private _domainEventsV2;
36
+ private _correlationIdV2;
37
+ constructor(entities?: T[]);
38
+ /** Factory method for creating instances - override in subclasses */
39
+ protected createInstance(entities: T[]): this;
40
+ /** Creates collection from array of entities - polymorphic, works with subclasses */
41
+ static from<T extends Entity>(this: new (entities: T[]) => EntityCollection<T>, entities: T[]): EntityCollection<T>;
42
+ /**
43
+ * Converts entity, array, or collection to plain array.
44
+ * Useful for repository save methods that accept multiple input types.
45
+ * Supports: single entity, arrays, Set, EntityCollection
46
+ *
47
+ * @example
48
+ * const entities = EntityCollection.toArrayFrom(entity);
49
+ * // Works with: single entity, array, Set, or EntityCollection
50
+ */
51
+ static toArrayFrom<T extends Entity>(entity: T | T[] | EntityCollection<T>): T[];
52
+ /** Returns total number of entities in collection */
53
+ get length(): number;
54
+ /** Checks if collection has no entities */
55
+ get isEmpty(): boolean;
56
+ /** Checks if collection has at least one entity */
57
+ get isNotEmpty(): boolean;
58
+ /**
59
+ * Enables native JavaScript/TypeScript boolean evaluation.
60
+ * Collection behaves like primitives in conditional contexts.
61
+ *
62
+ * Compatible with language keywords:
63
+ * - if (collection) { } // true if has entities
64
+ * - !collection // true if empty
65
+ * - collection && doSomething() // executes if not empty
66
+ * - collection || defaultValue // uses collection if not empty
67
+ * - collection ? a : b // ternary operator
68
+ * - while (collection) { } // loops while not empty
69
+ * - Boolean(collection) // explicit boolean conversion
70
+ * - +collection // converts to number (length)
71
+ * - String(collection) // converts to "EntityCollection(n)"
72
+ *
73
+ * @example
74
+ * if (priceLists) { console.log("Has items"); }
75
+ * const items = priceLists || new EntityCollection();
76
+ * !emptyCollection // true
77
+ */
78
+ [Symbol.toPrimitive](hint: string): boolean | number | string;
79
+ /**
80
+ * Returns numeric value for collection (length).
81
+ * Enables: +collection, Number(collection)
82
+ */
83
+ valueOf(): number;
84
+ /** Converts collection to plain array (creates new copy) */
85
+ toArray(): T[];
86
+ /** Gets entity at specific index (0-based) */
87
+ at(index: number): T | undefined;
88
+ /** Gets entity at specific index (0-based) */
89
+ get(index: number): T | undefined;
90
+ /** Checks if collection contains entity (uses Entity.equals) */
91
+ includes(entity: T): boolean;
92
+ /** Finds index of entity in collection (uses Entity.equals) */
93
+ indexOf(entity: T): number;
94
+ /** Concatenates multiple collections into new collection */
95
+ concat(...collections: EntityCollection<T>[]): this;
96
+ /** Returns subset of collection from start to end index */
97
+ slice(start?: number, end?: number): this;
98
+ /** Returns first entity in collection */
99
+ first(): T | undefined;
100
+ /** Returns last entity in collection */
101
+ last(): T | undefined;
102
+ /** Adds entity to collection (mutates) */
103
+ add(entity: T): this;
104
+ /** Adds multiple entities to collection (mutates) */
105
+ addAll(entities: T[]): this;
106
+ /** Removes entity from collection (mutates, uses Entity.equals) */
107
+ remove(entity: T): this;
108
+ /** Removes all entities from collection (mutates) */
109
+ clear(): this;
110
+ /** Makes collection iterable (use with for...of loops) */
111
+ [Symbol.iterator](): Iterator<T>;
112
+ /**
113
+ * Splits collection into chunks of specified size
114
+ * @example
115
+ * const pages = collection.chunk(10); // [[...10], [...10], ...]
116
+ * pages.forEach((page, i) => console.log(`Page ${i}: ${page.length} items`));
117
+ */
118
+ chunk(size: number): this[];
119
+ /** Counts entities matching predicate (returns length if no predicate) */
120
+ count(predicate?: (entity: T) => boolean): number;
121
+ /** Finds entity with minimum value from selector */
122
+ minBy(selector: (entity: T) => number): T | undefined;
123
+ /** Finds entity with maximum value from selector */
124
+ maxBy(selector: (entity: T) => number): T | undefined;
125
+ /** Sums numeric values from selector across all entities */
126
+ sumBy(selector: (entity: T) => number): number;
127
+ /** Calculates average of numeric values from selector */
128
+ averageBy(selector: (entity: T) => number): number;
129
+ /** Finds last entity matching predicate (searches from end) */
130
+ findLast(predicate: (entity: T) => boolean): T | undefined;
131
+ /**
132
+ * Converts collection to Map using key selector (for fast lookups)
133
+ * @example
134
+ * const priceListMap = collection.toMap(pl => pl.remoteId!);
135
+ * const priceList = priceListMap.get(123); // O(1) lookup
136
+ */
137
+ toMap<K>(keySelector: (entity: T) => K): Map<K, T>;
138
+ /**
139
+ * Converts collection to plain object using key and value selectors
140
+ * @example
141
+ * const names = collection.toRecord(pl => pl.remoteId!, pl => pl.name);
142
+ * // { 1: "Premium", 2: "Basic" }
143
+ */
144
+ toRecord<K extends string | number, V>(keySelector: (entity: T) => K, valueSelector: (entity: T) => V): Record<K, V>;
145
+ /** Checks if collection contains any of provided entities */
146
+ containsAny(entities: T[]): boolean;
147
+ /** Checks if collection contains all provided entities */
148
+ containsAll(entities: T[]): boolean;
149
+ /** Returns new collection with entities matching predicate */
150
+ filter(predicate: (entity: T, index: number) => boolean): this;
151
+ /** Transforms entities to new type, returns new collection */
152
+ map<R extends Entity>(mapper: (entity: T, index: number) => R): EntityCollection<R>;
153
+ /** Transforms entities to any type, returns plain array */
154
+ mapToArray<R>(mapper: (entity: T, index: number) => R): R[];
155
+ /** Maps and flattens results into new collection */
156
+ flatMap<R extends Entity>(mapper: (entity: T, index: number) => R[]): EntityCollection<R>;
157
+ /** Maps and flattens results into plain array */
158
+ flatMapToArray<R>(mapper: (entity: T, index: number) => R[]): R[];
159
+ /** Finds first entity matching predicate */
160
+ find(predicate: (entity: T) => boolean): T | undefined;
161
+ /** Finds index of first entity matching predicate */
162
+ findIndex(predicate: (entity: T) => boolean): number;
163
+ /** Checks if at least one entity matches predicate */
164
+ some(predicate: (entity: T) => boolean): boolean;
165
+ /** Checks if all entities match predicate */
166
+ every(predicate: (entity: T) => boolean): boolean;
167
+ /** Executes callback for each entity */
168
+ forEach(callback: (entity: T, index: number) => void): void;
169
+ /** Reduces collection to single value using reducer function */
170
+ reduce<R>(reducer: (acc: R, entity: T, index: number) => R, initialValue: R): R;
171
+ /** Sorts collection using compare function, returns new collection */
172
+ sort(compareFn: (a: T, b: T) => number): this;
173
+ /** Sorts collection by key selector, returns new collection */
174
+ sortBy(keySelector: (entity: T) => any): this;
175
+ /**
176
+ * Groups entities by key into Map of collections
177
+ * @example
178
+ * const byTyp = collection.groupBy(pl => pl.currencyId);
179
+ * // Map<number, EntityCollection<PriceList>>
180
+ * byType.get(1)?.forEach(pl => console.log(pl.name));
181
+ */
182
+ groupBy<K>(keySelector: (entity: T) => K): Map<K, this>;
183
+ /**
184
+ * Splits collection into [matching, non-matching] tuple
185
+ * @example
186
+ * const [active, inactive] = collection.partition(pl => pl.isActive);
187
+ */
188
+ partition(predicate: (entity: T) => boolean): [this, this];
189
+ /** Returns collection with unique entities (uses UUID by default or custom key selector) */
190
+ distinct(keySelector?: (entity: T) => any): this;
191
+ /** Returns first N entities from collection */
192
+ take(count: number): this;
193
+ /** Skips first N entities, returns rest */
194
+ skip(count: number): this;
195
+ /** Returns union of collections (no duplicates by uuid) */
196
+ union(other: this): this;
197
+ /** Returns entities present in both collections */
198
+ intersect(other: this): this;
199
+ /** Returns entities in this collection but not in other */
200
+ except(other: this): this;
201
+ /**
202
+ * Returns entities in this collection but not in other using custom selector
203
+ * @example
204
+ * const different = collection1.exceptBy(collection2, e => e.name);
205
+ */
206
+ exceptBy<K>(other: this, keySelector: (entity: T) => K): this;
207
+ /**
208
+ * Finds entity by UUID
209
+ * @example
210
+ * const entity = collection.findByUuid("abc-123-def");
211
+ */
212
+ findByUuid(uuid: string): T | undefined;
213
+ /**
214
+ * Finds entities by multiple UUIDs
215
+ * @example
216
+ * const entities = collection.findByUuids(["uuid1", "uuid2", "uuid3"]);
217
+ */
218
+ findByUuids(uuids: string[]): this;
219
+ /**
220
+ * Checks if collection contains entity with given UUID
221
+ * @example
222
+ * if (collection.hasUuid("abc-123")) { ... }
223
+ */
224
+ hasUuid(uuid: string): boolean;
225
+ /**
226
+ * Extracts all UUIDs as plain array
227
+ * @example
228
+ * const uuids = collection.getUuids();
229
+ * await deleteByUuids(uuids);
230
+ */
231
+ getUuids(): string[];
232
+ /**
233
+ * Creates a Map indexed by UUID for O(1) lookups
234
+ * @example
235
+ * const byUuid = collection.toMapByUuid();
236
+ * const entity = byUuid.get("abc-123"); // Fast lookup
237
+ */
238
+ toMapByUuid(): Map<string, T>;
239
+ addDomainEvent<E extends DomainEvent>(EventClass: DomainEventClass<E>, payload: Partial<E>): string;
240
+ addDomainEventWithEntities<E extends DomainEvent>(EventClass: DomainEventClass<E>): string;
241
+ getDomainEvents(): readonly DomainEvent[];
242
+ clearDomainEvents(): void;
243
+ publishAllDomainEvents(): Promise<void>;
244
+ publishAllDomainEventsSync(): Promise<void>;
245
+ publishDomainEvent<E extends DomainEvent>(EventClass: DomainEventClass<E>, payload: Partial<E>): Promise<void>;
246
+ publishDomainEventSync<E extends DomainEvent>(EventClass: DomainEventClass<E>, payload: Partial<E>): Promise<void>;
247
+ publishDomainEventWithEntities<E extends DomainEvent>(EventClass: DomainEventClass<E>): Promise<void>;
248
+ publishDomainEventWithEntitiesSync<E extends DomainEvent>(EventClass: DomainEventClass<E>): Promise<void>;
249
+ /**
250
+ * Serializes collection as array of entity JSONs.
251
+ * Collection is a manager, not an entity, so it serializes as pure entity list.
252
+ * @example
253
+ * const json = collection.asJSON();
254
+ * await saveToDatabase(json);
255
+ */
256
+ asJSON(pretty?: boolean): string;
257
+ /**
258
+ * Filters entities using criteria array. All criteria must match (AND).
259
+ * @example
260
+ * const filtered = collection.findByCriteria([
261
+ * { field: 'customerId', operator: '=', value: 123 },
262
+ * { field: 'state', operator: 'in', value: ['draft', 'posted'] }
263
+ * ]);
264
+ */
265
+ findByCriteria(criteria: ICriteria<T>[]): this;
266
+ /**
267
+ * Deserializes collection from array of entity JSONs.
268
+ * Collection is a manager, not an entity, so it deserializes from pure entity list.
269
+ * @example
270
+ * const collection = EntityCollection.fromJSON<PriceList>(json, PriceList);
271
+ */
272
+ static fromJSON<T extends Entity>(json: string | any, EntityClass?: new () => T): any;
273
+ }
274
+ /**
275
+ * Collection for RemoteEntity aggregates with DTO mapping support.
276
+ * Extends EntityCollection with fromRemoteDTO for batch entity creation.
277
+ *
278
+ * @example
279
+ * const collection = RemoteEntityCollection.fromRemoteDTO(
280
+ * remoteDTOs,
281
+ * PriceList
282
+ * );
283
+ * await collection.publishIds(PRICE_LISTS_SYNCED);
284
+ */
285
+ export declare class RemoteEntityCollection<T extends RemoteEntity> extends EntityCollection<T> {
286
+ /**
287
+ * Creates collection from remote DTOs using entity's fromRemoteDTO method
288
+ * @example
289
+ * const priceLists = RemoteEntityCollection.fromRemoteDTO(
290
+ * apiResponse.records,
291
+ * PriceList
292
+ * );
293
+ */
294
+ static fromRemoteDTO<T extends RemoteEntity>(dtos: any[], EntityClass: {
295
+ fromRemoteDTO: (dto: any) => T;
296
+ }): RemoteEntityCollection<T>;
297
+ /** Factory method override to create RemoteEntityCollection instances */
298
+ protected createInstance(entities: T[]): this;
299
+ /**
300
+ * Finds entity by remoteId
301
+ * Returns undefined if entity doesn't have remoteId or not found
302
+ * @example
303
+ * const customer = customers.findByRemoteId(123);
304
+ */
305
+ findByRemoteId(remoteId: number): T | undefined;
306
+ /**
307
+ * Finds entities by multiple remoteIds
308
+ * @example
309
+ * const products = collection.findByRemoteIds([1, 2, 3, 4, 5]);
310
+ */
311
+ findByRemoteIds(remoteIds: number[]): RemoteEntityCollection<T>;
312
+ /**
313
+ * Checks if collection contains entity with given remoteId
314
+ * @example
315
+ * if (customers.hasRemoteId(123)) { ... }
316
+ */
317
+ hasRemoteId(remoteId: number): boolean;
318
+ /**
319
+ * Returns entities that have remoteId set (synced with backend)
320
+ * @example
321
+ * const syncedEntities = collection.withRemoteId();
322
+ */
323
+ withRemoteId(): RemoteEntityCollection<T>;
324
+ /**
325
+ * Returns entities without remoteId (local-only, not synced)
326
+ * @example
327
+ * const localOnlyEntities = collection.withoutRemoteId();
328
+ */
329
+ withoutRemoteId(): RemoteEntityCollection<T>;
330
+ /**
331
+ * Extracts all remoteIds as plain array (filters out null/undefined)
332
+ * @example
333
+ * const remoteIds = collection.getRemoteIds();
334
+ * await syncWithBackend(remoteIds);
335
+ */
336
+ getRemoteIds(): number[];
337
+ /**
338
+ * Creates a Map indexed by remoteId for O(1) lookups
339
+ * Filters out entities without remoteId
340
+ * @example
341
+ * const byRemoteId = collection.toMapByRemoteId();
342
+ * const customer = byRemoteId.get(123); // Fast lookup
343
+ */
344
+ toMapByRemoteId(): Map<number, T>;
345
+ /**
346
+ * Returns entities in this collection but not in other, comparing by remoteId
347
+ * Useful for finding entities that exist locally but not in backend response
348
+ * @example
349
+ * const localOnly = localCollection.exceptByRemoteId(backendCollection);
350
+ */
351
+ exceptByRemoteId(other: RemoteEntityCollection<T>): RemoteEntityCollection<T>;
352
+ /**
353
+ * Returns entities present in both collections, comparing by remoteId
354
+ * Useful for finding entities that exist in both local and backend
355
+ * @example
356
+ * const inBoth = localCollection.intersectByRemoteId(backendCollection);
357
+ */
358
+ intersectByRemoteId(other: RemoteEntityCollection<T>): RemoteEntityCollection<T>;
359
+ /**
360
+ * Removes duplicates by remoteId (keeps first occurrence)
361
+ * Entities without remoteId are kept and deduplicated by uuid
362
+ * @example
363
+ * const unique = collection.distinctByRemoteId();
364
+ */
365
+ distinctByRemoteId(): RemoteEntityCollection<T>;
366
+ /**
367
+ * Filters entities pending synchronization with backend
368
+ * @example
369
+ * const pending = collection.findPendingSync();
370
+ * for (const entity of pending) {
371
+ * await pushToBackend(entity);
372
+ * }
373
+ */
374
+ findPendingSync(): RemoteEntityCollection<T>;
375
+ /**
376
+ * Filters entities successfully synced with backend
377
+ * @example
378
+ * const synced = collection.findSynced();
379
+ * console.log(`${synced.length} entities synced`);
380
+ */
381
+ findSynced(): RemoteEntityCollection<T>;
382
+ /**
383
+ * Filters entities that failed synchronization
384
+ * @example
385
+ * const failed = collection.findFailed();
386
+ * failed.forEach(e => logger.error(`Failed to sync: ${e.uuid}`));
387
+ */
388
+ findFailed(): RemoteEntityCollection<T>;
389
+ /**
390
+ * Groups entities by remote state
391
+ * @example
392
+ * const byState = collection.groupByRemoteState();
393
+ * console.log(`Pending: ${byState.get('PENDING')?.length}`);
394
+ */
395
+ groupByRemoteState(): Map<string, RemoteEntityCollection<T>>;
396
+ }