@sincpro/mobile 0.4.3 → 1.0.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 (197) hide show
  1. package/README.md +3 -3
  2. package/dist/adapters/JsonSerializer.adapter.d.ts +1 -1
  3. package/dist/adapters/JsonSerializer.adapter.js +2 -2
  4. package/dist/adapters/ReceiptExporter.adapter.js +10 -2
  5. package/dist/adapters/repositories/database_table.repository.d.ts +3 -2
  6. package/dist/adapters/repositories/database_table.repository.js +1 -1
  7. package/dist/adapters/repositories/document.repository.d.ts +81 -0
  8. package/dist/adapters/repositories/document.repository.js +653 -0
  9. package/dist/adapters/repositories/domain_event.repository.d.ts +17 -17
  10. package/dist/adapters/repositories/domain_event.repository.js +25 -31
  11. package/dist/adapters/repositories/domain_event_dead_letter.repository.d.ts +10 -10
  12. package/dist/adapters/repositories/domain_event_dead_letter.repository.js +14 -13
  13. package/dist/adapters/repositories/event_row.d.ts +13 -0
  14. package/dist/adapters/repositories/event_row.js +22 -0
  15. package/dist/adapters/repositories/sqlite_document_store.d.ts +33 -0
  16. package/dist/adapters/repositories/sqlite_document_store.js +201 -0
  17. package/dist/domain/connectivity/events.d.ts +5 -5
  18. package/dist/domain/connectivity/events.js +3 -3
  19. package/dist/domain/database/criteria.d.ts +19 -0
  20. package/dist/domain/database/criteria.js +36 -0
  21. package/dist/domain/database/criteria_clock.d.ts +8 -0
  22. package/dist/domain/database/criteria_clock.js +305 -0
  23. package/dist/domain/database/criteria_sql.d.ts +61 -0
  24. package/dist/domain/database/criteria_sql.js +476 -0
  25. package/dist/domain/database/database.d.ts +1 -0
  26. package/dist/domain/database/index.d.ts +3 -1
  27. package/dist/domain/database/index.js +3 -1
  28. package/dist/domain/database/migration_plan.d.ts +14 -0
  29. package/dist/domain/database/migration_plan.js +44 -0
  30. package/dist/domain/entity/change_tracking.d.ts +21 -0
  31. package/dist/domain/entity/change_tracking.js +71 -0
  32. package/dist/domain/entity/checks.d.ts +8 -0
  33. package/dist/domain/entity/checks.js +82 -0
  34. package/dist/domain/entity/entity.d.ts +39 -32
  35. package/dist/domain/entity/entity.js +94 -105
  36. package/dist/domain/entity/entity_collection.d.ts +15 -30
  37. package/dist/domain/entity/entity_collection.js +30 -121
  38. package/dist/domain/entity/index.d.ts +5 -0
  39. package/dist/domain/entity/index.js +5 -0
  40. package/dist/domain/entity/reconcile.d.ts +7 -0
  41. package/dist/domain/entity/reconcile.js +12 -0
  42. package/dist/domain/entity/relations.d.ts +27 -0
  43. package/dist/domain/entity/relations.js +69 -0
  44. package/dist/domain/entity/remote_sync.d.ts +4 -0
  45. package/dist/domain/entity/remote_sync.js +19 -0
  46. package/dist/domain/entity/values.d.ts +6 -0
  47. package/dist/domain/entity/values.js +13 -0
  48. package/dist/domain/events/catalog.d.ts +29 -0
  49. package/dist/domain/{events.js → events/catalog.js} +7 -11
  50. package/dist/domain/events/chain.d.ts +5 -0
  51. package/dist/domain/events/chain.js +6 -0
  52. package/dist/domain/{event_sourcing → events}/domain_event.d.ts +20 -22
  53. package/dist/domain/events/domain_event.js +227 -0
  54. package/dist/domain/events/index.d.ts +8 -0
  55. package/dist/domain/events/index.js +8 -0
  56. package/dist/domain/events/integration_event.d.ts +103 -0
  57. package/dist/domain/events/integration_event.js +72 -0
  58. package/dist/domain/events/label.d.ts +2 -0
  59. package/dist/domain/events/label.js +26 -0
  60. package/dist/domain/index.d.ts +0 -1
  61. package/dist/domain/index.js +0 -1
  62. package/dist/domain/print/events.d.ts +8 -4
  63. package/dist/domain/print/events.js +9 -4
  64. package/dist/domain/repositories/document_store.d.ts +33 -0
  65. package/dist/domain/repositories/document_store.js +5 -0
  66. package/dist/domain/repositories/hooks.d.ts +23 -0
  67. package/dist/domain/repositories/hooks.js +32 -0
  68. package/dist/domain/repositories/index.d.ts +4 -0
  69. package/dist/domain/repositories/index.js +4 -0
  70. package/dist/domain/{database → repositories}/repository.d.ts +9 -3
  71. package/dist/domain/settings.d.ts +4 -1
  72. package/dist/domain/settings.js +3 -0
  73. package/dist/domain/webview/events.d.ts +2 -2
  74. package/dist/domain/webview/events.js +2 -2
  75. package/dist/entrypoints/db/migrations.js +10 -10
  76. package/dist/entrypoints/queue/QueueProcessor.d.ts +1 -1
  77. package/dist/entrypoints/queue/activateDomain.subscriber.d.ts +2 -2
  78. package/dist/entrypoints/queue/activateDomain.subscriber.js +2 -2
  79. package/dist/entrypoints/queue/newAppSettings.handler.d.ts +2 -2
  80. package/dist/entrypoints/queue/newAppSettings.handler.js +1 -1
  81. package/dist/entrypoints/queue/printImage.subscriber.d.ts +1 -1
  82. package/dist/entrypoints/queue/printImage.subscriber.js +2 -2
  83. package/dist/entrypoints/queue/processWebViewMessage.subscriber.d.ts +1 -1
  84. package/dist/entrypoints/queue/processWebViewMessage.subscriber.js +1 -1
  85. package/dist/entrypoints/ui/AppShell.js +2 -2
  86. package/dist/entrypoints/ui/common_provider.d.ts +1 -13
  87. package/dist/entrypoints/ui/common_provider.js +4 -133
  88. package/dist/entrypoints/ui/domain_switcher.d.ts +2 -2
  89. package/dist/event_driven/index.d.ts +1 -0
  90. package/dist/event_driven/index.js +1 -0
  91. package/dist/{domain/event_sourcing/event_handler.d.ts → event_driven/subscriber.d.ts} +1 -1
  92. package/dist/exceptions.d.ts +21 -0
  93. package/dist/exceptions.js +30 -0
  94. package/dist/framework/base_module.d.ts +1 -1
  95. package/dist/framework/createApp.d.ts +3 -3
  96. package/dist/framework/domain_module.d.ts +1 -1
  97. package/dist/framework/feature.d.ts +26 -0
  98. package/dist/framework/feature.js +36 -0
  99. package/dist/framework/kernel.d.ts +1 -1
  100. package/dist/framework/kernel.js +17 -8
  101. package/dist/index.d.ts +1 -0
  102. package/dist/index.js +1 -0
  103. package/dist/infrastructure/database/connector.d.ts +2 -0
  104. package/dist/infrastructure/database/connector.js +22 -0
  105. package/dist/infrastructure/database/index.d.ts +1 -0
  106. package/dist/infrastructure/database/index.js +1 -0
  107. package/dist/infrastructure/database/schema.d.ts +9 -0
  108. package/dist/infrastructure/database/schema.js +61 -0
  109. package/dist/infrastructure/database/utils.d.ts +2 -0
  110. package/dist/infrastructure/database/utils.js +12 -4
  111. package/dist/infrastructure/event_chain.d.ts +6 -0
  112. package/dist/infrastructure/event_chain.js +25 -0
  113. package/dist/infrastructure/interceptor/intercept.d.ts +7 -2
  114. package/dist/infrastructure/interceptor/intercept.js +5 -2
  115. package/dist/infrastructure/telemetry/tracing/tracing_hooks.d.ts +9 -6
  116. package/dist/infrastructure/telemetry/tracing/tracing_hooks.js +61 -35
  117. package/dist/infrastructure/ui/UIEventBus.d.ts +3 -1
  118. package/dist/infrastructure/ui/UIEventBus.js +8 -1
  119. package/dist/infrastructure/ui/activity.d.ts +37 -0
  120. package/dist/infrastructure/ui/activity.js +84 -0
  121. package/dist/infrastructure/workers/CronWorker.d.ts +6 -4
  122. package/dist/infrastructure/workers/CronWorker.js +24 -18
  123. package/dist/infrastructure/workers/EventBus.d.ts +9 -5
  124. package/dist/infrastructure/workers/EventBus.js +68 -33
  125. package/dist/services/bluetooth.service.js +16 -14
  126. package/dist/services/dead_letter_queue.service.d.ts +7 -7
  127. package/dist/services/dead_letter_queue.service.js +0 -2
  128. package/dist/services/event.service.d.ts +3 -3
  129. package/dist/services/event.service.js +1 -1
  130. package/dist/services/network.service.d.ts +1 -1
  131. package/dist/services/network.service.js +17 -15
  132. package/dist/services/printer.service.d.ts +1 -1
  133. package/dist/services/printer.service.js +50 -44
  134. package/dist/tools/utils/date.js +4 -3
  135. package/dist/tools/utils/monetary.d.ts +6 -3
  136. package/dist/tools/utils/monetary.js +33 -21
  137. package/dist/tools/utils/serializer.d.ts +1 -1
  138. package/dist/tools/utils/serializer.js +32 -35
  139. package/dist/ui/activity/DeviceNotices.d.ts +1 -0
  140. package/dist/ui/activity/DeviceNotices.js +29 -0
  141. package/dist/ui/activity/ProcessToast.d.ts +2 -0
  142. package/dist/ui/activity/ProcessToast.js +71 -0
  143. package/dist/ui/{components/molecules → activity}/ProcessToastProvider.d.ts +1 -1
  144. package/dist/ui/activity/index.d.ts +4 -0
  145. package/dist/ui/activity/index.js +4 -0
  146. package/dist/ui/activity/useActivity.d.ts +9 -0
  147. package/dist/ui/activity/useActivity.js +48 -0
  148. package/dist/ui/components/atoms/DebugBanner.d.ts +1 -1
  149. package/dist/ui/components/molecules/BluetoothDeviceSelectorModal.d.ts +1 -1
  150. package/dist/ui/components/molecules/BluetoothDeviceSelectorModal.js +8 -2
  151. package/dist/ui/components/molecules/DeadLetterErrorBlock.d.ts +1 -1
  152. package/dist/ui/components/molecules/EventTimelineItem.d.ts +3 -3
  153. package/dist/ui/components/molecules/EventTimelineItem.js +1 -1
  154. package/dist/ui/components/molecules/GeoPermissionCard.d.ts +1 -1
  155. package/dist/ui/components/molecules/TimeZoneSelector.d.ts +1 -1
  156. package/dist/ui/components/molecules/TimeZoneSelectorModal.d.ts +1 -1
  157. package/dist/ui/components/molecules/TimeZoneSelectorModal.js +5 -3
  158. package/dist/ui/components/molecules/index.d.ts +1 -2
  159. package/dist/ui/components/molecules/index.js +1 -2
  160. package/dist/ui/components/organisms/BluetoothPrinterSelector.d.ts +1 -1
  161. package/dist/ui/components/organisms/BluetoothPrinterSelector.js +3 -0
  162. package/dist/ui/components/organisms/DatabaseInfoRow.d.ts +1 -1
  163. package/dist/ui/components/organisms/DeadLetterQueueRow.d.ts +5 -4
  164. package/dist/ui/components/organisms/EventRow.d.ts +4 -4
  165. package/dist/ui/components/organisms/EventRow.js +1 -1
  166. package/dist/ui/components/organisms/InjectableWebView.d.ts +2 -2
  167. package/dist/ui/components/organisms/InjectableWebView.js +6 -3
  168. package/dist/ui/components/organisms/Receipt.d.ts +2 -1
  169. package/dist/ui/components/organisms/TableInfoInfoRow.d.ts +1 -1
  170. package/dist/ui/screens/database/database.context.d.ts +2 -2
  171. package/dist/ui/screens/database/database.context.js +9 -18
  172. package/dist/ui/screens/database/database.json_detail.d.ts +1 -1
  173. package/dist/ui/screens/database/database.list.d.ts +1 -1
  174. package/dist/ui/screens/database/database.table_rows.d.ts +1 -1
  175. package/dist/ui/screens/dead_letter_queue/dead_letter_queue.context.d.ts +7 -7
  176. package/dist/ui/screens/dead_letter_queue/dead_letter_queue.list.d.ts +1 -1
  177. package/dist/ui/screens/events/events.context.d.ts +6 -6
  178. package/dist/ui/screens/events/events.context.js +20 -25
  179. package/dist/ui/screens/events/events.list.d.ts +1 -1
  180. package/package.json +51 -40
  181. package/dist/domain/event_sourcing/domain_event.js +0 -164
  182. package/dist/domain/event_sourcing/event.d.ts +0 -25
  183. package/dist/domain/event_sourcing/event.js +0 -25
  184. package/dist/domain/event_sourcing/index.d.ts +0 -2
  185. package/dist/domain/event_sourcing/index.js +0 -2
  186. package/dist/domain/events.d.ts +0 -33
  187. package/dist/infrastructure/ui/ToastHost.d.ts +0 -6
  188. package/dist/infrastructure/ui/ToastHost.js +0 -28
  189. package/dist/infrastructure/ui/events.d.ts +0 -1
  190. package/dist/infrastructure/ui/events.js +0 -1
  191. package/dist/ui/components/molecules/ProcessToast.d.ts +0 -8
  192. package/dist/ui/components/molecules/ProcessToast.js +0 -52
  193. /package/dist/domain/{repositories.d.ts → repositories/catalog.d.ts} +0 -0
  194. /package/dist/domain/{repositories.js → repositories/catalog.js} +0 -0
  195. /package/dist/domain/{database → repositories}/repository.js +0 -0
  196. /package/dist/{domain/event_sourcing/event_handler.js → event_driven/subscriber.js} +0 -0
  197. /package/dist/ui/{components/molecules → activity}/ProcessToastProvider.js +0 -0
package/README.md CHANGED
@@ -25,7 +25,7 @@ npx expo install @sincpro/mobile @sincpro/mobile-ui
25
25
  ```tsx
26
26
  // 1. Define your domain module
27
27
  import { DomainModule } from "@sincpro/mobile/framework/domain_module";
28
- import type { Subscriber } from "@sincpro/mobile/domain/event_sourcing";
28
+ import type { Subscriber } from "@sincpro/mobile/event_driven";
29
29
  import type { CronWorker } from "@sincpro/mobile/infrastructure/workers";
30
30
 
31
31
  class SalesModule extends DomainModule {
@@ -614,7 +614,7 @@ A `DomainModule` is the primary building block. Here is how to create one from s
614
614
 
615
615
  ```tsx
616
616
  import { DomainModule } from "@sincpro/mobile/framework/domain_module";
617
- import type { Subscriber } from "@sincpro/mobile/domain/event_sourcing";
617
+ import type { Subscriber } from "@sincpro/mobile/event_driven";
618
618
  import type { CronWorker } from "@sincpro/mobile/infrastructure/workers";
619
619
  import type { IMigration } from "@sincpro/mobile/domain/database";
620
620
 
@@ -1057,7 +1057,7 @@ import { orchestrator } from "@sincpro/mobile/framework/orchestrator";
1057
1057
  import { Kernel } from "@sincpro/mobile/framework/kernel";
1058
1058
 
1059
1059
  // Domain layer
1060
- import type { Subscriber } from "@sincpro/mobile/domain/event_sourcing";
1060
+ import type { Subscriber } from "@sincpro/mobile/event_driven";
1061
1061
  import { Entity } from "@sincpro/mobile/domain/entity";
1062
1062
  import { RemoteEntity } from "@sincpro/mobile/domain/entity";
1063
1063
  import type { IMigration } from "@sincpro/mobile/domain/database";
@@ -11,7 +11,7 @@ export declare const JsonSerializerAdapter: {
11
11
  /**
12
12
  * Normalize special types (Date, etc.) into JSON-friendly structures.
13
13
  */
14
- cleanData<T extends JsonValue>(data: T): JsonValue;
14
+ cleanData(data: unknown): JsonValue;
15
15
  /**
16
16
  * Recursively sort object keys and serialize without extra whitespace.
17
17
  */
@@ -1,3 +1,4 @@
1
+ import { valuesOf } from "@sincpro/client-framework";
1
2
  import * as Crypto from "expo-crypto";
2
3
  /**
3
4
  * Adapter for generating canonical JSON and SHA-256 hashes
@@ -8,8 +9,7 @@ export const JsonSerializerAdapter = {
8
9
  * Normalize special types (Date, etc.) into JSON-friendly structures.
9
10
  */
10
11
  cleanData(data) {
11
- const replacer = (_key, value) => value instanceof Date ? value.toISOString() : value;
12
- return JSON.parse(JSON.stringify(data, replacer));
12
+ return valuesOf(data);
13
13
  },
14
14
  /**
15
15
  * Recursively sort object keys and serialize without extra whitespace.
@@ -3,6 +3,14 @@ import * as Sharing from "expo-sharing";
3
3
  import { PDFDocument } from "pdf-lib";
4
4
  import { Platform } from "react-native";
5
5
  import { captureRef } from "react-native-view-shot";
6
+ /**
7
+ * view-shot 6 types a target as a class instance or a host node. React Native
8
+ * 0.88 types `View` as a function, so the ref we already hold is the same
9
+ * object at runtime and a different type here.
10
+ */
11
+ function shotTarget(viewRef) {
12
+ return viewRef;
13
+ }
6
14
  const DEFAULT_CONFIG = {
7
15
  RECEIPT_WIDTH_MM: 72,
8
16
  MM_TO_POINTS: 2.83464567,
@@ -16,7 +24,7 @@ function generateFileName(baseName, extension = "pdf") {
16
24
  return `${sanitized}_${Date.now()}.${extension}`;
17
25
  }
18
26
  async function captureViewToTmpFile(viewRef, quality) {
19
- const tmpUri = await captureRef(viewRef, {
27
+ const tmpUri = await captureRef(shotTarget(viewRef), {
20
28
  format: "jpg",
21
29
  quality,
22
30
  result: "tmpfile",
@@ -67,7 +75,7 @@ async function captureViewToBase64(viewRef, quality) {
67
75
  if (!viewRef.current)
68
76
  return null;
69
77
  try {
70
- const base64 = await captureRef(viewRef, {
78
+ const base64 = await captureRef(shotTarget(viewRef), {
71
79
  format: "png",
72
80
  quality,
73
81
  result: "base64",
@@ -1,4 +1,5 @@
1
- import { EntityCollection, ICriteria } from "../../domain/entity";
1
+ import { type DocumentCriteria } from "../../domain/database/criteria";
2
+ import { EntityCollection } from "../../domain/entity";
2
3
  import { ECommonRepository } from "../../domain/repositories";
3
4
  declare class DatabaseTableRepositoryImpl {
4
5
  readonly name = ECommonRepository.DATABASE_TABLE;
@@ -7,7 +8,7 @@ declare class DatabaseTableRepositoryImpl {
7
8
  save(entity: any | any[] | EntityCollection<any>): Promise<void>;
8
9
  remove(entity: any | any[]): Promise<void>;
9
10
  findById(id: number | string): Promise<any | null>;
10
- findByCriteria(criteria: ICriteria<any>[]): Promise<EntityCollection<any>>;
11
+ findByCriteria(_criteria: DocumentCriteria<any>): Promise<EntityCollection<any>>;
11
12
  }
12
13
  export declare const DatabaseTableRepository: DatabaseTableRepositoryImpl;
13
14
  export {};
@@ -22,7 +22,7 @@ class DatabaseTableRepositoryImpl {
22
22
  async findById(id) {
23
23
  throw new Error("Not implemented");
24
24
  }
25
- async findByCriteria(criteria) {
25
+ async findByCriteria(_criteria) {
26
26
  throw new Error("Not implemented");
27
27
  }
28
28
  }
@@ -0,0 +1,81 @@
1
+ import { type DocumentCriteria } from "../../domain/database/criteria";
2
+ import { Entity, ERemoteState } from "../../domain/entity/entity";
3
+ import { EntityCollection } from "../../domain/entity/entity_collection";
4
+ import { type AnyClass } from "../../domain/entity/relations";
5
+ import { type IntegrationEvent } from "../../domain/events/integration_event";
6
+ import { type ColumnValue, type DocumentStore, type Outbox, StoreMode } from "../../domain/repositories/document_store";
7
+ import { Hooks } from "../../domain/repositories/hooks";
8
+ import { type IRepository } from "../../domain/repositories/repository";
9
+ type EntityType<T extends Entity> = AnyClass<T>;
10
+ interface RepositoryOptions<T extends Entity> {
11
+ mode?: StoreMode;
12
+ hooks?: Hooks;
13
+ outbox?: Outbox;
14
+ columns?: (entity: T) => Record<string, ColumnValue>;
15
+ }
16
+ export declare class DocumentRepository<T extends Entity> implements IRepository<T, EntityCollection<T>> {
17
+ readonly type: EntityType<T>;
18
+ private readonly store;
19
+ private readonly options;
20
+ private readonly inflight;
21
+ constructor(type: EntityType<T>, store: DocumentStore, options?: RepositoryOptions<T>);
22
+ static reset(): void;
23
+ save(entity: T | T[] | EntityCollection<T>, options?: {
24
+ deliver?: boolean;
25
+ }): Promise<void>;
26
+ upsert(entity: T | T[] | EntityCollection<T>): Promise<void>;
27
+ remove(entity: T | T[]): Promise<void>;
28
+ removeById(uuid: string): Promise<void>;
29
+ publish(events: readonly IntegrationEvent[]): Promise<void>;
30
+ kick(): void;
31
+ findById(uuid: string): Promise<T | null>;
32
+ findByIdSync(uuid: string): T | null;
33
+ findByIds(uuids: string[]): Promise<EntityCollection<T>>;
34
+ findByIdsSync(uuids: string[]): EntityCollection<T>;
35
+ findAll(): Promise<EntityCollection<T>>;
36
+ findByCriteria(criteria: DocumentCriteria<T>): Promise<EntityCollection<T>>;
37
+ findByRemoteId(remoteId: number): Promise<T | null>;
38
+ findByRemoteIdSync(remoteId: number): T | null;
39
+ findByRemoteIds(remoteIds: number[]): Promise<EntityCollection<T>>;
40
+ findByRemoteState(state: ERemoteState | ERemoteState[]): Promise<EntityCollection<T>>;
41
+ findDirty(): Promise<EntityCollection<T>>;
42
+ acknowledge(entity: T, remoteId?: number): Promise<void>;
43
+ pull(local: T | null, incoming: T): Promise<T>;
44
+ private commit;
45
+ private assertCanWrite;
46
+ private persistIn;
47
+ private cascade;
48
+ private deleteIn;
49
+ private deleteById;
50
+ private writeRow;
51
+ private columnValues;
52
+ private flush;
53
+ private loadById;
54
+ private loadByIdSync;
55
+ private hydrate;
56
+ private hydrateSync;
57
+ private materialize;
58
+ private attachRelations;
59
+ private attachRelationsSync;
60
+ private resolveRelation;
61
+ private resolveRelationSync;
62
+ private resolveOne;
63
+ private resolveOneSync;
64
+ private findByColumn;
65
+ private readAll;
66
+ private afterSearch;
67
+ private runHooks;
68
+ private hooksOf;
69
+ private sqlTarget;
70
+ private repositoryFor;
71
+ private openSession;
72
+ private schedule;
73
+ private outbox;
74
+ }
75
+ export declare function sqliteDocuments<T extends Entity>(type: EntityType<T>, table: string, spec?: {
76
+ mode?: StoreMode;
77
+ hooks?: Hooks;
78
+ outbox?: Outbox;
79
+ columns?: Record<string, (entity: T) => ColumnValue>;
80
+ }): DocumentRepository<T>;
81
+ export {};