ofpos-shared-core 1.1.0 → 2.0.0-alpha.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.
- package/dist/IntegrationServices.d.ts +0 -4
- package/dist/PosCore.d.ts +46 -1
- package/dist/data/schema.d.ts +1 -3
- package/dist/finance/offinanceProjection.d.ts +37 -0
- package/dist/index.browser.mjs +4 -4
- package/dist/index.cjs.js +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.esm.js +4 -4
- package/dist/index.umd.js +4 -4
- package/dist/integration/NotificationAdapter.d.ts +6 -67
- package/dist/integration/authorizationService.d.ts +2 -19
- package/dist/integration/changeQueuePort.d.ts +5 -0
- package/dist/integration/loggerAdapter.d.ts +6 -43
- package/dist/integration/socket.d.ts +13 -0
- package/dist/integration/userService.d.ts +17 -32
- package/dist/models/User.d.ts +0 -6
- package/dist/services/bomService.d.ts +1 -1
- package/dist/services/categoryService.d.ts +1 -1
- package/dist/services/customerGroupService.d.ts +1 -1
- package/dist/services/customerService.d.ts +1 -1
- package/dist/services/expenseService.d.ts +1 -1
- package/dist/services/exportAdapter.d.ts +6 -46
- package/dist/services/financialSettingService.d.ts +1 -1
- package/dist/services/historyService.d.ts +1 -1
- package/dist/services/inventoryLogService.d.ts +2 -1
- package/dist/services/inventoryService.d.ts +7 -1
- package/dist/services/orderItemService.d.ts +1 -1
- package/dist/services/orderService.d.ts +1 -1
- package/dist/services/payableService.d.ts +1 -1
- package/dist/services/priceHistoryService.d.ts +1 -1
- package/dist/services/priceTierService.d.ts +1 -1
- package/dist/services/productService.d.ts +1 -1
- package/dist/services/promotionService.d.ts +1 -1
- package/dist/services/purchaseItemService.d.ts +1 -1
- package/dist/services/purchaseOrderItemService.d.ts +1 -1
- package/dist/services/purchaseOrderService.d.ts +1 -1
- package/dist/services/purchaseService.d.ts +3 -1
- package/dist/services/receivableService.d.ts +1 -1
- package/dist/services/reportScheduleService.d.ts +1 -1
- package/dist/services/reportingService.d.ts +1 -1
- package/dist/services/returnItemService.d.ts +1 -1
- package/dist/services/returnService.d.ts +1 -1
- package/dist/services/roleService.d.ts +1 -1
- package/dist/services/saleItemService.d.ts +1 -1
- package/dist/services/saleService.d.ts +2 -1
- package/dist/services/settlementService.d.ts +1 -1
- package/dist/services/shiftService.d.ts +1 -1
- package/dist/services/stockAdjustmentService.d.ts +1 -1
- package/dist/services/stockOpnameItemService.d.ts +1 -1
- package/dist/services/stockOpnameService.d.ts +1 -1
- package/dist/services/supplierService.d.ts +1 -1
- package/dist/services/taxRateService.d.ts +1 -1
- package/dist/services/transactionService.d.ts +1 -1
- package/dist/services/uiProductService.d.ts +0 -1
- package/dist/services/uomService.d.ts +1 -1
- package/dist/services/userService.d.ts +1 -1
- package/dist/stores/storageAdapter.d.ts +8 -39
- package/dist/stores/syncService.d.ts +16 -0
- package/package.json +27 -7
- package/dist/data/inMemoryDbAdapter.d.ts +0 -65
- package/dist/data/seed.d.ts +0 -370
- package/dist/integration/ofauthBridge.d.ts +0 -29
- package/dist/integration/ofauthCoreBridge.d.ts +0 -19
|
@@ -1,69 +1,8 @@
|
|
|
1
|
-
import { PosCore } from "../PosCore";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
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
|
|
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
|
|
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
|
|
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;
|
|
@@ -1,45 +1,8 @@
|
|
|
1
|
-
import { PosCore } from "../PosCore";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
99
|
+
* Menetapkan sesi pengguna aktif setelah autentikasi berhasil di Host App.
|
|
111
100
|
*/
|
|
112
|
-
|
|
101
|
+
setActiveSession(user: User): void;
|
|
113
102
|
/**
|
|
114
|
-
*
|
|
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
|
|
108
|
+
* @returns User jika ada sesi, undefined jika tidak ada.
|
|
124
109
|
*/
|
|
125
110
|
getActiveSession(): User | undefined;
|
|
126
111
|
}
|
package/dist/models/User.d.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -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
|
|
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
|
|
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
|
|
70
|
+
private changeQueue;
|
|
71
71
|
/**
|
|
72
72
|
* Initialize CustomerService.
|
|
73
73
|
* @param context - PosCore context
|
|
@@ -23,7 +23,7 @@ export interface IExpenseService {
|
|
|
23
23
|
export declare class ExpenseService implements IExpenseService {
|
|
24
24
|
private context;
|
|
25
25
|
private dbAdapter;
|
|
26
|
-
private
|
|
26
|
+
private changeQueue;
|
|
27
27
|
/**
|
|
28
28
|
* Initialize ExpenseService.
|
|
29
29
|
* @param context - PosCore context
|
|
@@ -1,48 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
26
|
+
private changeQueue;
|
|
27
27
|
/**
|
|
28
28
|
* Initialize OrderItemService.
|
|
29
29
|
* @param context - PosCore context
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
26
|
+
private changeQueue;
|
|
27
27
|
/**
|
|
28
28
|
* Initialize PurchaseOrderService.
|
|
29
29
|
* @param context - PosCore context
|
|
@@ -78,7 +78,7 @@ export interface IPurchaseService {
|
|
|
78
78
|
export declare class PurchaseService implements IPurchaseService {
|
|
79
79
|
private context;
|
|
80
80
|
private dbAdapter;
|
|
81
|
-
private
|
|
81
|
+
private changeQueue;
|
|
82
82
|
private docNumberPolicy;
|
|
83
83
|
private readonly defaultBaseCurrencyCode;
|
|
84
84
|
/**
|
|
@@ -88,6 +88,8 @@ export declare class PurchaseService implements IPurchaseService {
|
|
|
88
88
|
constructor(context: PosCore);
|
|
89
89
|
private roundCurrencyAmount;
|
|
90
90
|
private resolveCurrencySnapshot;
|
|
91
|
+
private toBaseQuantity;
|
|
92
|
+
private toBaseUnitCost;
|
|
91
93
|
private getCostingMethod;
|
|
92
94
|
private applyCostingPolicy;
|
|
93
95
|
/** Add new Purchase. */
|