ofpos-shared-core 1.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 (143) hide show
  1. package/README.md +37 -0
  2. package/dist/AdapterRegistry.d.ts +83 -0
  3. package/dist/DomainServices.d.ts +151 -0
  4. package/dist/IntegrationServices.d.ts +75 -0
  5. package/dist/PosCore.d.ts +216 -0
  6. package/dist/contracts/contractVersioning.d.ts +6 -0
  7. package/dist/contracts/crossDomainPrimitives.d.ts +5 -0
  8. package/dist/contracts/responseEnvelope.d.ts +6 -0
  9. package/dist/contracts/syncProtocol.d.ts +8 -0
  10. package/dist/data/DbAdapter.d.ts +7 -0
  11. package/dist/data/applyPendingMigrations.d.ts +18 -0
  12. package/dist/data/inMemoryDbAdapter.d.ts +65 -0
  13. package/dist/data/migrations.d.ts +12 -0
  14. package/dist/data/relations.d.ts +3 -0
  15. package/dist/data/schema.d.ts +9 -0
  16. package/dist/data/seed.d.ts +370 -0
  17. package/dist/index.browser.mjs +18 -0
  18. package/dist/index.browser.mjs.LEGAL.txt +46 -0
  19. package/dist/index.cjs.js +18 -0
  20. package/dist/index.cjs.js.LEGAL.txt +46 -0
  21. package/dist/index.d.ts +116 -0
  22. package/dist/index.esm.js +18 -0
  23. package/dist/index.esm.js.LEGAL.txt +46 -0
  24. package/dist/index.umd.js +18 -0
  25. package/dist/index.umd.js.LEGAL.txt +46 -0
  26. package/dist/integration/NotificationAdapter.d.ts +69 -0
  27. package/dist/integration/activityLogger.d.ts +44 -0
  28. package/dist/integration/activitySink.d.ts +8 -0
  29. package/dist/integration/apiService.d.ts +255 -0
  30. package/dist/integration/authorizationService.d.ts +225 -0
  31. package/dist/integration/backupScheduler.d.ts +75 -0
  32. package/dist/integration/checksum.d.ts +9 -0
  33. package/dist/integration/checksumAdapter.d.ts +8 -0
  34. package/dist/integration/configService.d.ts +431 -0
  35. package/dist/integration/defaultChecksumAdapter.d.ts +6 -0
  36. package/dist/integration/defaultEncryptionAdapter.d.ts +9 -0
  37. package/dist/integration/encryption.d.ts +95 -0
  38. package/dist/integration/encryptionAdapter.d.ts +8 -0
  39. package/dist/integration/httpAdapter.d.ts +9 -0
  40. package/dist/integration/loggerAdapter.d.ts +45 -0
  41. package/dist/integration/notificationService.d.ts +45 -0
  42. package/dist/integration/ofauthBridge.d.ts +29 -0
  43. package/dist/integration/ofauthCoreBridge.d.ts +19 -0
  44. package/dist/integration/platformAdapter.d.ts +8 -0
  45. package/dist/integration/roleAdapter.d.ts +61 -0
  46. package/dist/integration/socket.d.ts +60 -0
  47. package/dist/integration/socketAdapter.d.ts +8 -0
  48. package/dist/integration/userService.d.ts +126 -0
  49. package/dist/models/Bom.d.ts +17 -0
  50. package/dist/models/Category.d.ts +13 -0
  51. package/dist/models/Customer.d.ts +17 -0
  52. package/dist/models/CustomerGroup.d.ts +11 -0
  53. package/dist/models/Expense.d.ts +19 -0
  54. package/dist/models/FinancialSetting.d.ts +14 -0
  55. package/dist/models/History.d.ts +18 -0
  56. package/dist/models/InventoryLog.d.ts +23 -0
  57. package/dist/models/InventoryLot.d.ts +34 -0
  58. package/dist/models/KitchenTicket.d.ts +13 -0
  59. package/dist/models/KitchenTicketItem.d.ts +12 -0
  60. package/dist/models/LoyaltyAccount.d.ts +12 -0
  61. package/dist/models/LoyaltyLedger.d.ts +17 -0
  62. package/dist/models/Order.d.ts +45 -0
  63. package/dist/models/OrderItem.d.ts +19 -0
  64. package/dist/models/Payable.d.ts +23 -0
  65. package/dist/models/PriceHistory.d.ts +17 -0
  66. package/dist/models/PriceTier.d.ts +19 -0
  67. package/dist/models/Product.d.ts +25 -0
  68. package/dist/models/Promotion.d.ts +25 -0
  69. package/dist/models/Purchase.d.ts +29 -0
  70. package/dist/models/PurchaseItem.d.ts +21 -0
  71. package/dist/models/PurchaseOrder.d.ts +23 -0
  72. package/dist/models/PurchaseOrderItem.d.ts +19 -0
  73. package/dist/models/Receivable.d.ts +23 -0
  74. package/dist/models/ReportSchedule.d.ts +21 -0
  75. package/dist/models/Return.d.ts +57 -0
  76. package/dist/models/ReturnItem.d.ts +31 -0
  77. package/dist/models/Role.d.ts +13 -0
  78. package/dist/models/Sale.d.ts +43 -0
  79. package/dist/models/SaleItem.d.ts +19 -0
  80. package/dist/models/Settlement.d.ts +23 -0
  81. package/dist/models/Shift.d.ts +41 -0
  82. package/dist/models/StockAdjustment.d.ts +21 -0
  83. package/dist/models/StockOpname.d.ts +22 -0
  84. package/dist/models/StockOpnameItem.d.ts +27 -0
  85. package/dist/models/Supplier.d.ts +19 -0
  86. package/dist/models/TaxRate.d.ts +13 -0
  87. package/dist/models/Transaction.d.ts +32 -0
  88. package/dist/models/Uom.d.ts +15 -0
  89. package/dist/models/User.d.ts +21 -0
  90. package/dist/services/bomService.d.ts +71 -0
  91. package/dist/services/cartService.d.ts +65 -0
  92. package/dist/services/categoryService.d.ts +54 -0
  93. package/dist/services/customerGroupService.d.ts +47 -0
  94. package/dist/services/customerService.d.ts +133 -0
  95. package/dist/services/documentNumberPolicy.d.ts +15 -0
  96. package/dist/services/expenseService.d.ts +47 -0
  97. package/dist/services/exportAdapter.d.ts +48 -0
  98. package/dist/services/exportService.d.ts +263 -0
  99. package/dist/services/financialSettingService.d.ts +47 -0
  100. package/dist/services/historyService.d.ts +60 -0
  101. package/dist/services/inventoryLogService.d.ts +47 -0
  102. package/dist/services/inventoryService.d.ts +43 -0
  103. package/dist/services/orderItemService.d.ts +47 -0
  104. package/dist/services/orderService.d.ts +161 -0
  105. package/dist/services/payableService.d.ts +51 -0
  106. package/dist/services/priceHistoryService.d.ts +61 -0
  107. package/dist/services/priceTierService.d.ts +47 -0
  108. package/dist/services/pricingService.d.ts +192 -0
  109. package/dist/services/productService.d.ts +59 -0
  110. package/dist/services/promotionService.d.ts +47 -0
  111. package/dist/services/purchaseItemService.d.ts +47 -0
  112. package/dist/services/purchaseOrderItemService.d.ts +47 -0
  113. package/dist/services/purchaseOrderService.d.ts +47 -0
  114. package/dist/services/purchaseService.d.ts +130 -0
  115. package/dist/services/receivableService.d.ts +47 -0
  116. package/dist/services/reportScheduleService.d.ts +47 -0
  117. package/dist/services/reportingService.d.ts +251 -0
  118. package/dist/services/returnItemService.d.ts +47 -0
  119. package/dist/services/returnService.d.ts +123 -0
  120. package/dist/services/roleService.d.ts +47 -0
  121. package/dist/services/saleItemService.d.ts +47 -0
  122. package/dist/services/saleService.d.ts +154 -0
  123. package/dist/services/settlementService.d.ts +68 -0
  124. package/dist/services/shiftService.d.ts +92 -0
  125. package/dist/services/stockAdjustmentService.d.ts +47 -0
  126. package/dist/services/stockOpnameItemService.d.ts +47 -0
  127. package/dist/services/stockOpnameService.d.ts +51 -0
  128. package/dist/services/stockTransferService.d.ts +67 -0
  129. package/dist/services/supplierService.d.ts +51 -0
  130. package/dist/services/taxRateService.d.ts +47 -0
  131. package/dist/services/taxService.d.ts +63 -0
  132. package/dist/services/transactionService.d.ts +109 -0
  133. package/dist/services/uiProductService.d.ts +102 -0
  134. package/dist/services/uiTransactionService.d.ts +68 -0
  135. package/dist/services/uomService.d.ts +53 -0
  136. package/dist/services/userService.d.ts +47 -0
  137. package/dist/stores/cartStore.d.ts +109 -0
  138. package/dist/stores/eventBus.d.ts +55 -0
  139. package/dist/stores/sessionStore.d.ts +108 -0
  140. package/dist/stores/storageAdapter.d.ts +44 -0
  141. package/dist/stores/syncService.d.ts +90 -0
  142. package/dist/stores/syncStore.d.ts +163 -0
  143. package/package.json +82 -0
@@ -0,0 +1,45 @@
1
+ import { PosCore } from "../PosCore";
2
+ /**
3
+ * Antarmuka adapter logger untuk mencatat informasi dan error.
4
+ */
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
+ }
@@ -0,0 +1,45 @@
1
+ import { PosCore } from "../PosCore";
2
+ import { NotificationAdapter } from "./NotificationAdapter";
3
+ /**
4
+ * Antarmuka layanan notifikasi lokal.
5
+ */
6
+ export interface INotificationService {
7
+ /**
8
+ * Adapter yang bertanggung jawab mengirimkan notifikasi.
9
+ * Jika undefined, notifikasi akan di-queue untuk dikirim kemudian.
10
+ */
11
+ readonly notifier?: NotificationAdapter;
12
+ /**
13
+ * Inisialisasi dan kirim semua notifikasi yang tersisa di antrian.
14
+ * @returns Promise yang selesai saat antrian kosong.
15
+ */
16
+ initNotifications(): Promise<void>;
17
+ /**
18
+ * Kirim notifikasi segera atau masukkan ke antrian jika gagal.
19
+ * @param title Judul notifikasi.
20
+ * @param message Pesan notifikasi.
21
+ */
22
+ notify(title: string, message: string): void;
23
+ }
24
+ /**
25
+ * Implementasi layanan notifikasi dengan antrian dan retry.
26
+ */
27
+ export declare class NotificationService implements INotificationService {
28
+ private context;
29
+ private flushing;
30
+ notifier?: NotificationAdapter;
31
+ private notificationQueue;
32
+ private MAX_QUEUE;
33
+ /**
34
+ * @param context Konteks PosCore yang menyertakan adapter notifikasi.
35
+ */
36
+ constructor(context: PosCore);
37
+ /**
38
+ * Flush antrian notifikasi dengan mengirim setiap item.
39
+ */
40
+ initNotifications(): Promise<void>;
41
+ /**
42
+ * Kirim notifikasi segera atau tambahkan ke antrian jika gagal.
43
+ */
44
+ notify(title: string, message: string): void;
45
+ }
@@ -0,0 +1,29 @@
1
+ import { User } from '../models/User';
2
+ export type OfauthBridgeVerifyMethod = 'pin' | 'password';
3
+ export type OfauthBridgeLoginResult = {
4
+ status: 'authenticated';
5
+ user: User;
6
+ } | {
7
+ status: 'rejected';
8
+ reasonCode?: string;
9
+ } | {
10
+ status: 'fallback';
11
+ reasonCode?: string;
12
+ };
13
+ export interface OfauthBridgeLoginRequest {
14
+ username: string;
15
+ secret: string;
16
+ verifyMethod: OfauthBridgeVerifyMethod;
17
+ }
18
+ export interface OfauthBridgeLogoutRequest {
19
+ userId?: string;
20
+ reasonCode?: string;
21
+ }
22
+ export interface IOfauthBridge {
23
+ login(input: OfauthBridgeLoginRequest): Promise<OfauthBridgeLoginResult>;
24
+ logout(input: OfauthBridgeLogoutRequest): Promise<void>;
25
+ }
26
+ export declare class NoopOfauthBridge implements IOfauthBridge {
27
+ login(): Promise<OfauthBridgeLoginResult>;
28
+ logout(): Promise<void>;
29
+ }
@@ -0,0 +1,19 @@
1
+ import { PosCore } from '../PosCore';
2
+ import { IOfauthBridge, OfauthBridgeLoginRequest, OfauthBridgeLoginResult, OfauthBridgeLogoutRequest } from './ofauthBridge';
3
+ export declare class OfauthCoreBridge implements IOfauthBridge {
4
+ private readonly context;
5
+ private runtime?;
6
+ private ofauthTables?;
7
+ private readonly sessionByUserId;
8
+ constructor(context: PosCore);
9
+ private get db();
10
+ private loadOfauthModule;
11
+ private ensureRuntime;
12
+ private get tables();
13
+ private findLocalUser;
14
+ private findIdentityByPrincipal;
15
+ private ensureIdentityFromUser;
16
+ private ensureAssignment;
17
+ login(input: OfauthBridgeLoginRequest): Promise<OfauthBridgeLoginResult>;
18
+ logout(input: OfauthBridgeLogoutRequest): Promise<void>;
19
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Bridge file for RFC 001 extraction phase.
3
+ *
4
+ * Source of truth for generic platform contract is now `ofcore`.
5
+ * Shared-core keeps this path for backward import compatibility.
6
+ */
7
+ export { DefaultPlatformAdapter } from 'ofcore';
8
+ export type { PlatformAdapter } from 'ofcore';
@@ -0,0 +1,61 @@
1
+ import { RoleData, Role as RoleRecord } from '../models/Role';
2
+ import { PosCore } from '../PosCore';
3
+ /**
4
+ * IRoleAdapter mendefinisikan operasi CRUD untuk entitas role
5
+ * dengan dukungan versioning dan soft delete.
6
+ */
7
+ export interface IRoleAdapter {
8
+ /**
9
+ * Membuat role baru dengan versioned soft delete.
10
+ */
11
+ create(data: RoleData): Promise<RoleRecord>;
12
+ /**
13
+ * Memperbarui sebagian data role yang ada dan menaikkan version & timestamp.
14
+ */
15
+ update(id: string, data: Partial<RoleData>): Promise<RoleRecord>;
16
+ /**
17
+ * Soft-delete role dengan menandai deleted=true dan menaikkan version.
18
+ */
19
+ delete(id: string): Promise<void>;
20
+ /**
21
+ * Mengambil semua role non-deleted, diurutkan berdasarkan lastModified DESC.
22
+ */
23
+ queryAll(): Promise<RoleRecord[]>;
24
+ /**
25
+ * Mengambil satu role berdasarkan ID; mengembalikan null jika tidak ditemukan atau sudah dihapus.
26
+ */
27
+ getById(id: string): Promise<RoleRecord | null>;
28
+ }
29
+ /**
30
+ * RoleAdapter implementasi IRoleAdapter yang menggunakan DbAdapter
31
+ * untuk mengelola tabel 'roles' dengan cache internal.
32
+ */
33
+ export declare class RoleAdapter {
34
+ private context;
35
+ private readonly db;
36
+ private recordCache;
37
+ private allCache;
38
+ /**
39
+ * Membuat instance RoleAdapter.
40
+ * @param context Konteks PosCore yang menyimpan registry aplikasi.
41
+ */
42
+ constructor(context: PosCore);
43
+ /** @inheritDoc */
44
+ create(data: RoleData): Promise<RoleRecord>;
45
+ /** @inheritDoc */
46
+ update(id: string, data: Partial<RoleData>): Promise<RoleRecord>;
47
+ /** @inheritDoc */
48
+ delete(id: string): Promise<void>;
49
+ /** @inheritDoc */
50
+ queryAll(): Promise<RoleRecord[]>;
51
+ /** @inheritDoc */
52
+ getById(id: string): Promise<RoleRecord | null>;
53
+ /**
54
+ * Mengonversi record mentah dari database menjadi RoleRecord.
55
+ */
56
+ private denormalize;
57
+ /**
58
+ * Memvalidasi bahwa field yang dibutuhkan ada di data input.
59
+ */
60
+ private validateData;
61
+ }
@@ -0,0 +1,60 @@
1
+ import { PosCore } from '../PosCore';
2
+ /**
3
+ * ISocketService mendefinisikan metode untuk mendapatkan instance Socket.
4
+ */
5
+ export interface ISocketService {
6
+ /**
7
+ * Mengembalikan instance socket aktif (engine-specific).
8
+ */
9
+ getSocket(): any;
10
+ /**
11
+ * Menutup koneksi socket dan membersihkan listener.
12
+ */
13
+ shutdown?(): void;
14
+ }
15
+ /**
16
+ * ISocketServiceStatic menyediakan utilitas statis untuk SocketService.
17
+ */
18
+ export interface ISocketServiceStatic {
19
+ /**
20
+ * Membuat fungsi debounced dengan delay tertentu.
21
+ * @param fn Fungsi asli.
22
+ * @param delay Waktu delay dalam milidetik (default 1000).
23
+ * @returns Fungsi dengan debounce.
24
+ */
25
+ debounce<F extends (...args: any[]) => void>(fn: F, delay?: number): F;
26
+ }
27
+ /**
28
+ * SocketService mengelola koneksi Socket.io dan memicu sinkronisasi
29
+ * melalui SyncService saat event tertentu terjadi.
30
+ */
31
+ export declare class SocketService {
32
+ private context;
33
+ private url;
34
+ private readonly socketAdapter;
35
+ private unsubscribeDataChanged?;
36
+ private unsubscribeConnect?;
37
+ private unsubscribeDisconnect?;
38
+ private debouncedSync;
39
+ private readonly syncStore?;
40
+ private readonly syncService;
41
+ /**
42
+ * Membuat fungsi debounced.
43
+ * @param fn Fungsi yang akan didebounce.
44
+ * @param delay Waktu delay dalam ms.
45
+ */
46
+ static debounce<F extends (...args: any[]) => void>(fn: F, delay?: number): F;
47
+ /**
48
+ * Membuat instance SocketService.
49
+ * @param context Konteks PosCore.
50
+ * @param url URL server socket (default http://localhost:3000).
51
+ */
52
+ constructor(context: PosCore, url?: string);
53
+ private initSocket;
54
+ /**
55
+ * Mendapatkan instance Socket.io.
56
+ * @returns Instance Socket.
57
+ */
58
+ getSocket(): any;
59
+ shutdown(): void;
60
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Bridge file for RFC extraction phase.
3
+ *
4
+ * Source of truth for generic realtime socket contract is `ofcore`.
5
+ * Shared-core keeps this path for backward import compatibility.
6
+ */
7
+ export { InMemorySocketAdapter } from 'ofcore';
8
+ export type { SocketAdapter, SocketConnectOptions, SocketEventHandler } from 'ofcore';
@@ -0,0 +1,126 @@
1
+ import { QueryOptions } from 'ofcore';
2
+ import { PosCore } from '../PosCore';
3
+ import { User } from '../models/User';
4
+ /**
5
+ * Data untuk menambah user baru.
6
+ */
7
+ export interface NewUser {
8
+ username: string;
9
+ password: string;
10
+ role: string;
11
+ }
12
+ /**
13
+ * Data untuk memperbarui user yang ada.
14
+ */
15
+ export interface UpdateUser {
16
+ id: string;
17
+ username: string;
18
+ role: string;
19
+ password?: string;
20
+ }
21
+ /**
22
+ * Struktur hasil setelah user dibuat.
23
+ */
24
+ export interface CreatedUser {
25
+ id: string;
26
+ username: string;
27
+ pinHash: string;
28
+ role: string;
29
+ version: number;
30
+ lastModified: string;
31
+ deleted: false;
32
+ failedAttempts: number;
33
+ isLocked: boolean;
34
+ }
35
+ /**
36
+ * Struktur hasil setelah user diperbarui.
37
+ */
38
+ export interface UpdatedUser {
39
+ id: string;
40
+ username: string;
41
+ role: string;
42
+ version: number;
43
+ lastModified: string;
44
+ password?: string;
45
+ failedAttempts?: number;
46
+ isLocked?: boolean;
47
+ }
48
+ /**
49
+ * Hasil operasi delete user.
50
+ */
51
+ export interface DeleteResult {
52
+ id: string;
53
+ queued: boolean;
54
+ }
55
+ /**
56
+ * Record user yang tersimpan di lokal.
57
+ */
58
+ /**
59
+ * IUserService mendefinisikan operasi terkait user,
60
+ * termasuk login lokal dan online.
61
+ */
62
+ export interface IUserService {
63
+ addUser(user: NewUser): Promise<CreatedUser>;
64
+ updateUser(id: string, user: UpdateUser): Promise<UpdatedUser>;
65
+ deleteUser(id: string): Promise<DeleteResult>;
66
+ fetchUsers(options: QueryOptions): Promise<User[]>;
67
+ loginLocal(username: string, pin: string): Promise<User | null>;
68
+ loginOnline(username: string, password: string): Promise<User | null>;
69
+ logoutLocal(): void;
70
+ getActiveSession(): User | undefined;
71
+ }
72
+ /**
73
+ * UserService implementasi IUserService yang menggunakan DbAdapter
74
+ * dan PlatformAdapter untuk manajemen user dan autentikasi.
75
+ */
76
+ export declare class UserService implements IUserService {
77
+ private context;
78
+ private readonly dbAdapter;
79
+ private readonly syncStore?;
80
+ 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;
88
+ /**
89
+ * Membuat instance UserService.
90
+ * @param context Konteks PosCore.
91
+ */
92
+ constructor(context: PosCore);
93
+ /**
94
+ * Menambah user baru ke database lokal dan mengantri perubahan untuk sinkronisasi.
95
+ */
96
+ addUser(user: NewUser): Promise<CreatedUser>;
97
+ /**
98
+ * Memperbarui data user yang ada dan mengantri perubahan untuk sinkronisasi.
99
+ */
100
+ updateUser(id: string, user: UpdateUser): Promise<UpdatedUser>;
101
+ /**
102
+ * Menghapus user secara lokal dan mengantri operasi delete untuk sinkronisasi.
103
+ */
104
+ deleteUser(id: string): Promise<DeleteResult>;
105
+ /**
106
+ * Mengambil daftar user non-deleted dari database lokal.
107
+ */
108
+ fetchUsers(options: QueryOptions): Promise<User[]>;
109
+ /**
110
+ * Melakukan login offline dengan memverifikasi PIN dan mengelola percobaan gagal.
111
+ */
112
+ loginLocal(username: string, pin: string): Promise<User | null>;
113
+ /**
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.
119
+ */
120
+ logoutLocal(): void;
121
+ /**
122
+ * Mendapatkan sesi pengguna yang sedang aktif.
123
+ * @returns UserRecord jika ada sesi, undefined jika tidak ada.
124
+ */
125
+ getActiveSession(): User | undefined;
126
+ }
@@ -0,0 +1,17 @@
1
+ export declare const bomTable = "boms";
2
+ export interface Bom {
3
+ id: string;
4
+ parentItemId: string | null;
5
+ componentItemId: string | null;
6
+ quantity: number;
7
+ uomId: string;
8
+ version: number;
9
+ lastModified: string;
10
+ deleted: boolean;
11
+ }
12
+ export interface BomData {
13
+ parentItemId: string | null;
14
+ componentItemId: string | null;
15
+ quantity: number;
16
+ uomId: string;
17
+ }
@@ -0,0 +1,13 @@
1
+ export declare const categoryTable = "categories";
2
+ export interface Category {
3
+ id: string;
4
+ name: string;
5
+ parentId: string | null;
6
+ version: number;
7
+ lastModified: string;
8
+ deleted: boolean;
9
+ }
10
+ export interface CategoryData {
11
+ name: string;
12
+ parentId: string | null;
13
+ }
@@ -0,0 +1,17 @@
1
+ export declare const customerTable = "customers";
2
+ export interface Customer {
3
+ id: string;
4
+ name: string;
5
+ phone: string | null;
6
+ email: string | null;
7
+ groupId: string | null;
8
+ version: number;
9
+ lastModified: string;
10
+ deleted: boolean;
11
+ }
12
+ export interface CustomerData {
13
+ name: string;
14
+ phone: string | null;
15
+ email: string | null;
16
+ groupId: string | null;
17
+ }
@@ -0,0 +1,11 @@
1
+ export declare const customerGroupTable = "customer_groups";
2
+ export interface CustomerGroup {
3
+ id: string;
4
+ name: string;
5
+ version: number;
6
+ lastModified: string;
7
+ deleted: boolean;
8
+ }
9
+ export interface CustomerGroupData {
10
+ name: string;
11
+ }
@@ -0,0 +1,19 @@
1
+ export declare const expenseTable = "expenses";
2
+ export interface Expense {
3
+ id: string;
4
+ userId: string;
5
+ amount: number;
6
+ category: string;
7
+ description: string | null;
8
+ date: string;
9
+ version: number;
10
+ lastModified: string;
11
+ deleted: boolean;
12
+ }
13
+ export interface ExpenseData {
14
+ userId: string;
15
+ amount: number;
16
+ category: string;
17
+ description: string | null;
18
+ date: string;
19
+ }
@@ -0,0 +1,14 @@
1
+ export declare const financialSettingTable = "financial_settings";
2
+ export interface FinancialSetting {
3
+ id: string;
4
+ costingMethod: string;
5
+ defaultExpenseAccount: string | null;
6
+ fiscalYearStart: string;
7
+ version: number;
8
+ lastModified: string;
9
+ }
10
+ export interface FinancialSettingData {
11
+ costingMethod: string;
12
+ defaultExpenseAccount: string | null;
13
+ fiscalYearStart: string;
14
+ }
@@ -0,0 +1,18 @@
1
+ export declare const historyTable = "histories";
2
+ export interface History {
3
+ id: string;
4
+ tableName: string;
5
+ recordId: string;
6
+ action: string;
7
+ changes: any;
8
+ userId: string | null;
9
+ timestamp: string;
10
+ }
11
+ export interface HistoryData {
12
+ tableName: string;
13
+ recordId: string;
14
+ action: string;
15
+ changes: any;
16
+ userId: string | null;
17
+ timestamp: string;
18
+ }
@@ -0,0 +1,23 @@
1
+ export declare const inventoryLogTable = "inventory_logs";
2
+ export type InventoryLogReferenceType = 'sale' | 'purchase' | 'sale_return' | 'purchase_return' | 'stock_adjustment' | 'stock_opname';
3
+ export interface InventoryLog {
4
+ id: string;
5
+ productId: string;
6
+ change: number;
7
+ reason: string;
8
+ referenceType: InventoryLogReferenceType;
9
+ referenceId: string;
10
+ userId: string;
11
+ timestamp: string;
12
+ note: string | null;
13
+ }
14
+ export interface InventoryLogData {
15
+ productId: string;
16
+ change: number;
17
+ reason: string;
18
+ referenceType: InventoryLogReferenceType;
19
+ referenceId: string;
20
+ userId: string;
21
+ timestamp: string;
22
+ note: string | null;
23
+ }
@@ -0,0 +1,34 @@
1
+ export declare const inventoryLotTable = "inventory_lots";
2
+ export type InventoryLotStatus = 'active' | 'depleted' | 'expired';
3
+ export interface InventoryLot {
4
+ id: string;
5
+ productId: string;
6
+ purchaseId: string;
7
+ purchaseItemId: string;
8
+ purchaseOrderId: string | null;
9
+ purchaseOrderItemId: string | null;
10
+ lotNumber: string | null;
11
+ serialNumber: string | null;
12
+ expiryDate: string | null;
13
+ quantity: number;
14
+ remainingQuantity: number;
15
+ status: InventoryLotStatus;
16
+ note: string | null;
17
+ version: number;
18
+ lastModified: string;
19
+ deleted: boolean;
20
+ }
21
+ export interface InventoryLotData {
22
+ productId: string;
23
+ purchaseId: string;
24
+ purchaseItemId: string;
25
+ purchaseOrderId: string | null;
26
+ purchaseOrderItemId: string | null;
27
+ lotNumber: string | null;
28
+ serialNumber: string | null;
29
+ expiryDate: string | null;
30
+ quantity: number;
31
+ remainingQuantity: number;
32
+ status: InventoryLotStatus;
33
+ note: string | null;
34
+ }
@@ -0,0 +1,13 @@
1
+ export declare const kitchenTicketTable = "kitchen_tickets";
2
+ export interface KitchenTicket {
3
+ id: string;
4
+ orderId: string;
5
+ station: string;
6
+ status: 'queued' | 'in_progress' | 'ready' | 'served' | 'canceled';
7
+ note: string | null;
8
+ createdBy: string | null;
9
+ createdAt: string;
10
+ version: number;
11
+ lastModified: string;
12
+ deleted: boolean;
13
+ }
@@ -0,0 +1,12 @@
1
+ export declare const kitchenTicketItemTable = "kitchen_ticket_items";
2
+ export interface KitchenTicketItem {
3
+ id: string;
4
+ ticketId: string;
5
+ orderItemId: string;
6
+ course: string | null;
7
+ status: 'queued' | 'in_progress' | 'ready' | 'served' | 'canceled';
8
+ note: string | null;
9
+ version: number;
10
+ lastModified: string;
11
+ deleted: boolean;
12
+ }
@@ -0,0 +1,12 @@
1
+ export declare const loyaltyAccountTable = "loyalty_accounts";
2
+ export interface LoyaltyAccount {
3
+ id: string;
4
+ customerId: string;
5
+ pointsBalance: number;
6
+ totalEarned: number;
7
+ totalRedeemed: number;
8
+ totalExpired: number;
9
+ version: number;
10
+ lastModified: string;
11
+ deleted: boolean;
12
+ }
@@ -0,0 +1,17 @@
1
+ export declare const loyaltyLedgerTable = "loyalty_ledgers";
2
+ export interface LoyaltyLedger {
3
+ id: string;
4
+ customerId: string;
5
+ entryType: 'earn' | 'redeem' | 'expire' | 'adjustment';
6
+ points: number;
7
+ availablePoints: number;
8
+ expiresAt: string | null;
9
+ consumedAt: string | null;
10
+ referenceType: string | null;
11
+ referenceId: string | null;
12
+ note: string | null;
13
+ date: string;
14
+ version: number;
15
+ lastModified: string;
16
+ deleted: boolean;
17
+ }