ofpos-shared-core 1.1.0 → 2.0.0-alpha.1

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 (69) hide show
  1. package/dist/DomainServices.d.ts +2 -1
  2. package/dist/IntegrationServices.d.ts +0 -4
  3. package/dist/PosCore.d.ts +51 -1
  4. package/dist/data/schema.d.ts +1 -3
  5. package/dist/finance/offinanceProjection.d.ts +196 -0
  6. package/dist/index.browser.mjs +4 -4
  7. package/dist/index.browser.mjs.LEGAL.txt +1 -1
  8. package/dist/index.cjs.js +4 -4
  9. package/dist/index.cjs.js.LEGAL.txt +1 -1
  10. package/dist/index.d.ts +5 -4
  11. package/dist/index.esm.js +4 -4
  12. package/dist/index.esm.js.LEGAL.txt +1 -1
  13. package/dist/index.umd.js +4 -4
  14. package/dist/index.umd.js.LEGAL.txt +1 -1
  15. package/dist/integration/NotificationAdapter.d.ts +6 -67
  16. package/dist/integration/authorizationService.d.ts +2 -19
  17. package/dist/integration/changeQueuePort.d.ts +5 -0
  18. package/dist/integration/loggerAdapter.d.ts +6 -43
  19. package/dist/integration/socket.d.ts +13 -0
  20. package/dist/integration/userService.d.ts +17 -32
  21. package/dist/models/User.d.ts +0 -6
  22. package/dist/services/bomService.d.ts +1 -1
  23. package/dist/services/categoryService.d.ts +1 -1
  24. package/dist/services/customerGroupService.d.ts +1 -1
  25. package/dist/services/customerService.d.ts +1 -1
  26. package/dist/services/expenseService.d.ts +5 -2
  27. package/dist/services/exportAdapter.d.ts +6 -46
  28. package/dist/services/financialSettingService.d.ts +1 -1
  29. package/dist/services/historyService.d.ts +1 -1
  30. package/dist/services/inventoryLogService.d.ts +2 -1
  31. package/dist/services/inventoryService.d.ts +7 -1
  32. package/dist/services/orderItemService.d.ts +1 -1
  33. package/dist/services/orderService.d.ts +1 -1
  34. package/dist/services/payableService.d.ts +1 -1
  35. package/dist/services/priceHistoryService.d.ts +1 -1
  36. package/dist/services/priceTierService.d.ts +1 -1
  37. package/dist/services/productService.d.ts +1 -1
  38. package/dist/services/promotionService.d.ts +1 -1
  39. package/dist/services/purchaseItemService.d.ts +1 -1
  40. package/dist/services/purchaseOrderItemService.d.ts +1 -1
  41. package/dist/services/purchaseOrderService.d.ts +1 -1
  42. package/dist/services/purchaseService.d.ts +7 -2
  43. package/dist/services/receivableService.d.ts +1 -1
  44. package/dist/services/reportScheduleService.d.ts +1 -1
  45. package/dist/services/reportingService.d.ts +1 -1
  46. package/dist/services/returnItemService.d.ts +1 -1
  47. package/dist/services/returnService.d.ts +5 -2
  48. package/dist/services/roleService.d.ts +1 -1
  49. package/dist/services/runtimeSupport.d.ts +12 -0
  50. package/dist/services/saleItemService.d.ts +1 -1
  51. package/dist/services/saleService.d.ts +6 -2
  52. package/dist/services/settlementService.d.ts +5 -2
  53. package/dist/services/shiftService.d.ts +1 -1
  54. package/dist/services/stockAdjustmentService.d.ts +1 -1
  55. package/dist/services/stockOpnameItemService.d.ts +1 -1
  56. package/dist/services/stockOpnameService.d.ts +1 -1
  57. package/dist/services/supplierService.d.ts +1 -1
  58. package/dist/services/taxRateService.d.ts +1 -1
  59. package/dist/services/transactionService.d.ts +5 -2
  60. package/dist/services/uiProductService.d.ts +0 -1
  61. package/dist/services/uomService.d.ts +1 -1
  62. package/dist/services/userService.d.ts +1 -1
  63. package/dist/stores/storageAdapter.d.ts +8 -39
  64. package/dist/stores/syncService.d.ts +16 -0
  65. package/package.json +28 -7
  66. package/dist/data/inMemoryDbAdapter.d.ts +0 -65
  67. package/dist/data/seed.d.ts +0 -370
  68. package/dist/integration/ofauthBridge.d.ts +0 -29
  69. package/dist/integration/ofauthCoreBridge.d.ts +0 -19
@@ -39,7 +39,7 @@ uuidv7/dist/index.js:
39
39
  /**
40
40
  * uuidv7: A JavaScript implementation of UUID version 7
41
41
  *
42
- * Copyright 2021-2025 LiosK
42
+ * Copyright 2021-2026 LiosK
43
43
  *
44
44
  * @license Apache-2.0
45
45
  * @packageDocumentation
@@ -1,69 +1,8 @@
1
- import { PosCore } from "../PosCore";
2
1
  /**
3
- * Opsi untuk menampilkan notifikasi lokal.
2
+ * Bridge file for RFC extraction phase.
3
+ *
4
+ * Source of truth for generic notification contract/defaults is `ofcore`.
5
+ * Shared-core keeps this path for backward import compatibility.
4
6
  */
5
- export interface NotificationOptions {
6
- /**
7
- * ID channel notifikasi.
8
- */
9
- channelId?: string;
10
- /**
11
- * Judul notifikasi.
12
- */
13
- title: string;
14
- /**
15
- * Isi pesan notifikasi.
16
- */
17
- message: string;
18
- [key: string]: any;
19
- }
20
- /**
21
- * Antarmuka adapter untuk notifikasi lokal.
22
- */
23
- export interface NotificationAdapter {
24
- /**
25
- * Konfigurasi adapter notifikasi.
26
- * @param options Opsi konfigurasi.
27
- */
28
- configure(options: any): void;
29
- /**
30
- * Buat channel notifikasi baru.
31
- * @param options Opsi channel.
32
- */
33
- createChannel(options: {
34
- channelId: string;
35
- channelName: string;
36
- importance?: number;
37
- }): void;
38
- /**
39
- * Tampilkan notifikasi lokal segera.
40
- * @param options Opsi notifikasi.
41
- */
42
- localNotification(options: NotificationOptions): void;
43
- }
44
- /**
45
- * Implementasi NotificationAdapter yang tidak melakukan apa-apa.
46
- */
47
- export declare class NoopNotificationAdapter implements NotificationAdapter {
48
- private context;
49
- /**
50
- * @param context Konteks PosCore (tidak digunakan).
51
- */
52
- constructor(context: PosCore);
53
- /**
54
- * Konfigurasi tidak melakukan apa-apa.
55
- */
56
- configure(options: any): void;
57
- /**
58
- * Pembuatan channel tidak melakukan apa-apa.
59
- */
60
- createChannel(options: {
61
- channelId: string;
62
- channelName: string;
63
- importance?: number;
64
- }): void;
65
- /**
66
- * Pengiriman notifikasi tidak melakukan apa-apa.
67
- */
68
- localNotification(options: NotificationOptions): void;
69
- }
7
+ export type { NotificationAdapter, NotificationOptions } from 'ofcore';
8
+ export { NoopNotificationAdapter } from 'ofcore';
@@ -1,6 +1,5 @@
1
1
  import { RoleData, Role } from '../models/Role';
2
2
  import { PosCore } from '../PosCore';
3
- import { User } from '../models/User';
4
3
  import { QueryOptions } from 'ofcore';
5
4
  export type GranularAuthorizationAction = 'void' | 'refund' | 'settlement_adjustment' | 'credit_limit_approval';
6
5
  export interface GranularAuthorizationRule {
@@ -93,14 +92,6 @@ export interface IAuthorizationService {
93
92
  can(user: {
94
93
  role: string;
95
94
  }, permission: string): Promise<boolean>;
96
- /**
97
- * Verifikasi PIN lokal terhadap hash yang disimpan.
98
- *
99
- * @param user Objek User.
100
- * @param pin PIN yang diinput.
101
- * @returns true jika PIN valid.
102
- */
103
- verifyLocalPin(user: User, pin: string): boolean;
104
95
  /**
105
96
  * Mendapatkan kontrak policy otorisasi granular canonical.
106
97
  */
@@ -121,12 +112,12 @@ export interface IAuthorizationService {
121
112
  }): Promise<GranularAuthorizationDecision>;
122
113
  }
123
114
  /**
124
- * Layanan otorisasi yang menggunakan RoleAdapter dan SyncStore.
115
+ * Layanan otorisasi yang menggunakan RoleAdapter dan queue port sinkronisasi.
125
116
  */
126
117
  export declare class AuthorizationService {
127
118
  private context;
128
119
  private roleAdapter?;
129
- private syncStore?;
120
+ private changeQueue;
130
121
  /**
131
122
  * Membuat instance AuthorizationService.
132
123
  *
@@ -200,14 +191,6 @@ export declare class AuthorizationService {
200
191
  can(user: {
201
192
  role: string;
202
193
  }, permission: string): Promise<boolean>;
203
- /**
204
- * Verifikasi PIN lokal terhadap hash yang disimpan di user.
205
- *
206
- * @param user Objek User.
207
- * @param pin PIN yang diinput.
208
- * @returns true jika PIN valid; false jika tidak atau terjadi error.
209
- */
210
- verifyLocalPin(user: User, pin: string): boolean;
211
194
  getGranularPolicy(): GranularAuthorizationPolicy;
212
195
  private normalizeRole;
213
196
  private isApprovalValid;
@@ -0,0 +1,5 @@
1
+ import { PosCore } from '../PosCore';
2
+ export interface ChangeQueuePort {
3
+ enqueue(change: unknown): void;
4
+ }
5
+ export declare function createChangeQueuePort(context: PosCore): ChangeQueuePort;
@@ -1,45 +1,8 @@
1
- import { PosCore } from "../PosCore";
2
1
  /**
3
- * Antarmuka adapter logger untuk mencatat informasi dan error.
2
+ * Bridge file for RFC extraction phase.
3
+ *
4
+ * Source of truth for generic logger contract/defaults is `ofcore`.
5
+ * Shared-core keeps this path for backward import compatibility.
4
6
  */
5
- export interface LoggerAdapter {
6
- /**
7
- * Inisialisasi logger dengan opsi tertentu (opsional).
8
- * @param options Konfigurasi inisialisasi.
9
- */
10
- init?(options?: any): void;
11
- /**
12
- * Catat pesan informasi.
13
- * @param message Pesan yang akan dicatat.
14
- * @param context Konteks tambahan.
15
- */
16
- logInfo(message: string, context?: Record<string, any>): void;
17
- /**
18
- * Catat error.
19
- * @param error Objek error atau pesan error.
20
- * @param context Konteks tambahan.
21
- */
22
- logError(error: any, context?: Record<string, any>): void;
23
- }
24
- /**
25
- * Implementasi LoggerAdapter yang menggunakan console.
26
- */
27
- export declare class ConsoleLoggerAdapter implements LoggerAdapter {
28
- private context;
29
- /**
30
- * @param context Konteks PosCore (tidak digunakan saat ini).
31
- */
32
- constructor(context: PosCore);
33
- /**
34
- * Inisialisasi adapter (tidak melakukan apa-apa saat ini).
35
- */
36
- init(options?: any): void;
37
- /**
38
- * Log informasi ke console.
39
- */
40
- logInfo(message: string, context?: Record<string, any>): void;
41
- /**
42
- * Log error ke console.
43
- */
44
- logError(error: any, context?: Record<string, any>): void;
45
- }
7
+ export type { LoggerAdapter } from 'ofcore';
8
+ export { ConsoleLoggerAdapter } from 'ofcore';
@@ -12,6 +12,13 @@ export interface ISocketService {
12
12
  */
13
13
  shutdown?(): void;
14
14
  }
15
+ /**
16
+ * Implementasi socket no-op untuk mode host-managed sync orchestration.
17
+ */
18
+ export declare class NoopSocketService implements ISocketService {
19
+ getSocket(): any;
20
+ shutdown(): void;
21
+ }
15
22
  /**
16
23
  * ISocketServiceStatic menyediakan utilitas statis untuk SocketService.
17
24
  */
@@ -38,6 +45,7 @@ export declare class SocketService {
38
45
  private debouncedSync;
39
46
  private readonly syncStore?;
40
47
  private readonly syncService;
48
+ private started;
41
49
  /**
42
50
  * Membuat fungsi debounced.
43
51
  * @param fn Fungsi yang akan didebounce.
@@ -50,6 +58,11 @@ export declare class SocketService {
50
58
  * @param url URL server socket (default http://localhost:3000).
51
59
  */
52
60
  constructor(context: PosCore, url?: string);
61
+ /**
62
+ * Aktifkan koneksi socket dan listener runtime.
63
+ * Idempotent: aman dipanggil berkali-kali.
64
+ */
65
+ start(): Promise<void>;
53
66
  private initSocket;
54
67
  /**
55
68
  * Mendapatkan instance Socket.io.
@@ -6,7 +6,6 @@ import { User } from '../models/User';
6
6
  */
7
7
  export interface NewUser {
8
8
  username: string;
9
- password: string;
10
9
  role: string;
11
10
  }
12
11
  /**
@@ -16,7 +15,6 @@ export interface UpdateUser {
16
15
  id: string;
17
16
  username: string;
18
17
  role: string;
19
- password?: string;
20
18
  }
21
19
  /**
22
20
  * Struktur hasil setelah user dibuat.
@@ -24,13 +22,10 @@ export interface UpdateUser {
24
22
  export interface CreatedUser {
25
23
  id: string;
26
24
  username: string;
27
- pinHash: string;
28
25
  role: string;
29
26
  version: number;
30
27
  lastModified: string;
31
28
  deleted: false;
32
- failedAttempts: number;
33
- isLocked: boolean;
34
29
  }
35
30
  /**
36
31
  * Struktur hasil setelah user diperbarui.
@@ -41,9 +36,6 @@ export interface UpdatedUser {
41
36
  role: string;
42
37
  version: number;
43
38
  lastModified: string;
44
- password?: string;
45
- failedAttempts?: number;
46
- isLocked?: boolean;
47
39
  }
48
40
  /**
49
41
  * Hasil operasi delete user.
@@ -56,50 +48,47 @@ export interface DeleteResult {
56
48
  * Record user yang tersimpan di lokal.
57
49
  */
58
50
  /**
59
- * IUserService mendefinisikan operasi terkait user,
60
- * termasuk login lokal dan online.
51
+ * IUserService mendefinisikan operasi terkait user.
52
+ * Autentikasi (login) dilakukan di level Host App melalui ofauth-shared-core,
53
+ * kemudian diinjeksikan ke Core menggunakan setActiveSession.
61
54
  */
62
55
  export interface IUserService {
63
56
  addUser(user: NewUser): Promise<CreatedUser>;
64
57
  updateUser(id: string, user: UpdateUser): Promise<UpdatedUser>;
65
58
  deleteUser(id: string): Promise<DeleteResult>;
66
59
  fetchUsers(options: QueryOptions): Promise<User[]>;
67
- loginLocal(username: string, pin: string): Promise<User | null>;
68
- loginOnline(username: string, password: string): Promise<User | null>;
60
+ setActiveSession(user: User): void;
69
61
  logoutLocal(): void;
70
62
  getActiveSession(): User | undefined;
71
63
  }
72
64
  /**
73
65
  * UserService implementasi IUserService yang menggunakan DbAdapter
74
- * dan PlatformAdapter untuk manajemen user dan autentikasi.
66
+ * untuk manajemen user.
75
67
  */
76
68
  export declare class UserService implements IUserService {
77
69
  private context;
78
70
  private readonly dbAdapter;
79
- private readonly syncStore?;
80
71
  private activeSession?;
81
- private platformAdapter;
82
- private readonly onlineAuthAttemptState;
83
- private readonly legacyAuthFallbackEnvKey;
84
- private readonly ofauthBridgeRequiredEnvKey;
85
- private get ofauthBridge();
86
- private isLegacyEmergencyFallbackEnabled;
87
- private isOfauthBridgeRequired;
72
+ private authorityProvisioningError;
88
73
  /**
89
74
  * Membuat instance UserService.
90
75
  * @param context Konteks PosCore.
91
76
  */
92
77
  constructor(context: PosCore);
93
78
  /**
94
- * Menambah user baru ke database lokal dan mengantri perubahan untuk sinkronisasi.
79
+ * @deprecated
80
+ * User provisioning identitas tidak boleh dilakukan dari domain POS.
81
+ * Gunakan authority auth (ofauth-*) lalu sinkronkan proyeksi user ke POS.
95
82
  */
96
83
  addUser(user: NewUser): Promise<CreatedUser>;
97
84
  /**
98
- * Memperbarui data user yang ada dan mengantri perubahan untuk sinkronisasi.
85
+ * @deprecated
86
+ * Identitas user tidak boleh diperbarui langsung dari domain POS.
99
87
  */
100
88
  updateUser(id: string, user: UpdateUser): Promise<UpdatedUser>;
101
89
  /**
102
- * Menghapus user secara lokal dan mengantri operasi delete untuk sinkronisasi.
90
+ * @deprecated
91
+ * Identitas user tidak boleh dihapus langsung dari domain POS.
103
92
  */
104
93
  deleteUser(id: string): Promise<DeleteResult>;
105
94
  /**
@@ -107,20 +96,16 @@ export declare class UserService implements IUserService {
107
96
  */
108
97
  fetchUsers(options: QueryOptions): Promise<User[]>;
109
98
  /**
110
- * Melakukan login offline dengan memverifikasi PIN dan mengelola percobaan gagal.
99
+ * Menetapkan sesi pengguna aktif setelah autentikasi berhasil di Host App.
111
100
  */
112
- loginLocal(username: string, pin: string): Promise<User | null>;
101
+ setActiveSession(user: User): void;
113
102
  /**
114
- * Melakukan login online dengan API eksternal dan menyimpan user untuk penggunaan offline.
115
- */
116
- loginOnline(username: string, password: string): Promise<User | null>;
117
- /**
118
- * Logout lokal: menghapus sesi aktif dan memperbarui session store.
103
+ * Logout lokal: menghapus sesi aktif.
119
104
  */
120
105
  logoutLocal(): void;
121
106
  /**
122
107
  * Mendapatkan sesi pengguna yang sedang aktif.
123
- * @returns UserRecord jika ada sesi, undefined jika tidak ada.
108
+ * @returns User jika ada sesi, undefined jika tidak ada.
124
109
  */
125
110
  getActiveSession(): User | undefined;
126
111
  }
@@ -2,20 +2,14 @@ export declare const userTable = "users";
2
2
  export interface User {
3
3
  id: string;
4
4
  username: string;
5
- pinHash: string | null;
6
5
  role: string;
7
6
  email: string | null;
8
- failedAttempts: number | null;
9
- isLocked: boolean | null;
10
7
  version: number;
11
8
  lastModified: string;
12
9
  deleted: boolean;
13
10
  }
14
11
  export interface UserData {
15
12
  username: string;
16
- pinHash: string | null;
17
13
  role: string;
18
14
  email: string | null;
19
- failedAttempts: number | null;
20
- isLocked: boolean | null;
21
15
  }
@@ -35,7 +35,7 @@ export interface IBomService {
35
35
  export declare class BomService implements IBomService {
36
36
  private context;
37
37
  private dbAdapter;
38
- private syncStore?;
38
+ private changeQueue;
39
39
  /**
40
40
  * Initialize BomService.
41
41
  * @param context - PosCore context
@@ -28,7 +28,7 @@ export interface ICategoryService {
28
28
  export declare class CategoryService implements ICategoryService {
29
29
  private context;
30
30
  private dbAdapter;
31
- private syncStore?;
31
+ private changeQueue;
32
32
  /**
33
33
  * Initialize CategoryService.
34
34
  * @param context - PosCore context
@@ -23,7 +23,7 @@ export interface ICustomerGroupService {
23
23
  export declare class CustomerGroupService implements ICustomerGroupService {
24
24
  private context;
25
25
  private dbAdapter;
26
- private syncStore?;
26
+ private changeQueue;
27
27
  /**
28
28
  * Initialize CustomerGroupService.
29
29
  * @param context - PosCore context
@@ -67,7 +67,7 @@ export interface ICustomerService {
67
67
  export declare class CustomerService implements ICustomerService {
68
68
  private context;
69
69
  private dbAdapter;
70
- private syncStore?;
70
+ private changeQueue;
71
71
  /**
72
72
  * Initialize CustomerService.
73
73
  * @param context - PosCore context
@@ -1,6 +1,7 @@
1
1
  import { PosCore } from '../PosCore';
2
2
  import { DbAdapter, QueryOptions } from 'ofcore';
3
3
  import { Expense, ExpenseData } from '../models/Expense';
4
+ import type { ServiceRuntimeOptions } from './runtimeSupport';
4
5
  /** Service interface for Expense operations. */
5
6
  export interface IExpenseService {
6
7
  /** Add new Expense. */
@@ -22,13 +23,15 @@ export interface IExpenseService {
22
23
  /** Service implementation for Expense operations. */
23
24
  export declare class ExpenseService implements IExpenseService {
24
25
  private context;
26
+ private readonly _runtimeOptions;
25
27
  private dbAdapter;
26
- private syncStore?;
28
+ private changeQueue;
27
29
  /**
28
30
  * Initialize ExpenseService.
29
31
  * @param context - PosCore context
30
32
  */
31
- constructor(context: PosCore);
33
+ constructor(context: PosCore, _runtimeOptions?: Partial<ServiceRuntimeOptions>);
34
+ private emitFinanceProjection;
32
35
  /** Add new Expense. */
33
36
  addExpense(data: ExpenseData, tx?: DbAdapter): Promise<Expense>;
34
37
  /** Update existing Expense. */
@@ -1,48 +1,8 @@
1
1
  /**
2
- * Adapter ekspor dokumen, abstraksi untuk menulis dan membagikan file.
2
+ * Bridge file for RFC extraction phase.
3
+ *
4
+ * Source of truth for generic export contract/defaults is `ofcore`.
5
+ * Shared-core keeps this path for backward import compatibility.
3
6
  */
4
- import { PosCore } from "../PosCore";
5
- /**
6
- * Antarmuka adapter ekspor dokumen.
7
- */
8
- export interface ExportAdapter {
9
- /**
10
- * Dapatkan path dokumen berdasarkan nama file.
11
- * @param fileName Nama file yang diinginkan.
12
- */
13
- getDocumentPath(fileName: string): string;
14
- /**
15
- * Tulis konten ke file pada path tertentu.
16
- * @param path Lokasi file.
17
- * @param content Konten yang akan ditulis.
18
- */
19
- writeFile(path: string, content: string): Promise<void>;
20
- /**
21
- * Bagikan file melalui mekanisme platform.
22
- * @param path Lokasi file yang akan dibagikan.
23
- */
24
- share(path: string): Promise<void>;
25
- }
26
- /**
27
- * Implementasi default ExportAdapter yang melempar error pada operasi tertentu.
28
- */
29
- export declare class DefaultExportAdapter implements ExportAdapter {
30
- private context;
31
- /**
32
- * Buat instance DefaultExportAdapter.
33
- * @param context Konteks PosCore.
34
- */
35
- constructor(context: PosCore);
36
- /**
37
- * Dapatkan path dokumen (default hanya nama file).
38
- */
39
- getDocumentPath(fileName: string): string;
40
- /**
41
- * Tulis konten ke file (tidak diimplementasikan pada platform ini).
42
- */
43
- writeFile(path: string, content: string): Promise<void>;
44
- /**
45
- * Bagikan file (tidak diimplementasikan pada platform ini).
46
- */
47
- share(path: string): Promise<void>;
48
- }
7
+ export type { ExportAdapter } from 'ofcore';
8
+ export { DefaultExportAdapter } from 'ofcore';
@@ -23,7 +23,7 @@ export interface IFinancialSettingService {
23
23
  export declare class FinancialSettingService implements IFinancialSettingService {
24
24
  private context;
25
25
  private dbAdapter;
26
- private syncStore?;
26
+ private changeQueue;
27
27
  /**
28
28
  * Initialize FinancialSettingService.
29
29
  * @param context - PosCore context
@@ -30,7 +30,7 @@ export interface IHistoryService {
30
30
  export declare class HistoryService implements IHistoryService {
31
31
  private context;
32
32
  private dbAdapter;
33
- private syncStore?;
33
+ private changeQueue;
34
34
  /**
35
35
  * Initialize HistoryService.
36
36
  * @param context - PosCore context
@@ -23,7 +23,7 @@ export interface IInventoryLogService {
23
23
  export declare class InventoryLogService implements IInventoryLogService {
24
24
  private context;
25
25
  private dbAdapter;
26
- private syncStore?;
26
+ private changeQueue;
27
27
  /**
28
28
  * Initialize InventoryLogService.
29
29
  * @param context - PosCore context
@@ -44,4 +44,5 @@ export declare class InventoryLogService implements IInventoryLogService {
44
44
  }>;
45
45
  /** Duplicate InventoryLog by ID. */
46
46
  duplicateInventoryLog(originalId: string, tx?: DbAdapter): Promise<InventoryLog>;
47
+ private emitStockChanged;
47
48
  }
@@ -9,6 +9,8 @@ export interface IInventoryService {
9
9
  updateStock(productId: string, change: number, reason: string, referenceType?: string, referenceId?: string, tx?: DbAdapter): Promise<void>;
10
10
  /** Baru: untuk host app */
11
11
  rebuildStockCache(): Promise<void>;
12
+ invalidateProductStock(productId: string): void;
13
+ invalidateProductsStock(productIds: string[]): void;
12
14
  clearStockCache(): void;
13
15
  getLowStockProducts(threshold?: number, limit?: number): Promise<Array<{
14
16
  productId: string;
@@ -19,9 +21,11 @@ export interface IInventoryService {
19
21
  export declare class InventoryService implements IInventoryService {
20
22
  private context;
21
23
  private adapter;
22
- private syncStore;
24
+ private changeQueue;
23
25
  private stockCache;
24
26
  private isRebuilding;
27
+ private readonly onStockChanged;
28
+ private readonly onStockRebuild;
25
29
  constructor(context: PosCore);
26
30
  /** API publik paling simpel: langsung return number */
27
31
  getStock(productId: string): Promise<number>;
@@ -29,6 +33,8 @@ export declare class InventoryService implements IInventoryService {
29
33
  updateStock(productId: string, change: number, reason: string, referenceType?: string, referenceId?: string, tx?: DbAdapter): Promise<void>;
30
34
  /** Untuk host app: rebuild cache saat startup atau setelah sync besar */
31
35
  rebuildStockCache(): Promise<void>;
36
+ invalidateProductStock(productId: string): void;
37
+ invalidateProductsStock(productIds: string[]): void;
32
38
  clearStockCache(): void;
33
39
  private computeStockFromLogs;
34
40
  /**
@@ -23,7 +23,7 @@ export interface IOrderItemService {
23
23
  export declare class OrderItemService implements IOrderItemService {
24
24
  private context;
25
25
  private dbAdapter;
26
- private syncStore?;
26
+ private changeQueue;
27
27
  /**
28
28
  * Initialize OrderItemService.
29
29
  * @param context - PosCore context
@@ -81,7 +81,7 @@ export interface IOrderService {
81
81
  export declare class OrderService implements IOrderService {
82
82
  private context;
83
83
  private dbAdapter;
84
- private syncStore?;
84
+ private changeQueue;
85
85
  private docNumberPolicy;
86
86
  /**
87
87
  * Initialize OrderService.
@@ -25,7 +25,7 @@ export interface IPayableService {
25
25
  export declare class PayableService implements IPayableService {
26
26
  private context;
27
27
  private dbAdapter;
28
- private syncStore?;
28
+ private changeQueue;
29
29
  /**
30
30
  * Initialize PayableService.
31
31
  * @param context - PosCore context
@@ -30,7 +30,7 @@ export interface IPriceHistoryService {
30
30
  export declare class PriceHistoryService implements IPriceHistoryService {
31
31
  private context;
32
32
  private dbAdapter;
33
- private syncStore?;
33
+ private changeQueue;
34
34
  /**
35
35
  * Initialize PriceHistoryService.
36
36
  * @param context - PosCore context
@@ -23,7 +23,7 @@ export interface IPriceTierService {
23
23
  export declare class PriceTierService implements IPriceTierService {
24
24
  private context;
25
25
  private dbAdapter;
26
- private syncStore?;
26
+ private changeQueue;
27
27
  /**
28
28
  * Initialize PriceTierService.
29
29
  * @param context - PosCore context
@@ -29,7 +29,7 @@ export interface IProductService {
29
29
  export declare class ProductService implements IProductService {
30
30
  private context;
31
31
  private dbAdapter;
32
- private syncStore?;
32
+ private changeQueue;
33
33
  /**
34
34
  * Initialize ProductService.
35
35
  * @param context - PosCore context
@@ -23,7 +23,7 @@ export interface IPromotionService {
23
23
  export declare class PromotionService implements IPromotionService {
24
24
  private context;
25
25
  private dbAdapter;
26
- private syncStore?;
26
+ private changeQueue;
27
27
  /**
28
28
  * Initialize PromotionService.
29
29
  * @param context - PosCore context
@@ -23,7 +23,7 @@ export interface IPurchaseItemService {
23
23
  export declare class PurchaseItemService implements IPurchaseItemService {
24
24
  private context;
25
25
  private dbAdapter;
26
- private syncStore?;
26
+ private changeQueue;
27
27
  /**
28
28
  * Initialize PurchaseItemService.
29
29
  * @param context - PosCore context
@@ -23,7 +23,7 @@ export interface IPurchaseOrderItemService {
23
23
  export declare class PurchaseOrderItemService implements IPurchaseOrderItemService {
24
24
  private context;
25
25
  private dbAdapter;
26
- private syncStore?;
26
+ private changeQueue;
27
27
  /**
28
28
  * Initialize PurchaseOrderItemService.
29
29
  * @param context - PosCore context
@@ -23,7 +23,7 @@ export interface IPurchaseOrderService {
23
23
  export declare class PurchaseOrderService implements IPurchaseOrderService {
24
24
  private context;
25
25
  private dbAdapter;
26
- private syncStore?;
26
+ private changeQueue;
27
27
  /**
28
28
  * Initialize PurchaseOrderService.
29
29
  * @param context - PosCore context