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.
- package/dist/DomainServices.d.ts +2 -1
- package/dist/IntegrationServices.d.ts +0 -4
- package/dist/PosCore.d.ts +51 -1
- package/dist/data/schema.d.ts +1 -3
- package/dist/finance/offinanceProjection.d.ts +196 -0
- package/dist/index.browser.mjs +4 -4
- package/dist/index.browser.mjs.LEGAL.txt +1 -1
- package/dist/index.cjs.js +4 -4
- package/dist/index.cjs.js.LEGAL.txt +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.esm.js +4 -4
- package/dist/index.esm.js.LEGAL.txt +1 -1
- package/dist/index.umd.js +4 -4
- package/dist/index.umd.js.LEGAL.txt +1 -1
- 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 +5 -2
- 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 +7 -2
- 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 +5 -2
- package/dist/services/roleService.d.ts +1 -1
- package/dist/services/runtimeSupport.d.ts +12 -0
- package/dist/services/saleItemService.d.ts +1 -1
- package/dist/services/saleService.d.ts +6 -2
- package/dist/services/settlementService.d.ts +5 -2
- 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 +5 -2
- 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 +28 -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
|
@@ -2,6 +2,7 @@ import { PosCore } from '../PosCore';
|
|
|
2
2
|
import { DbAdapter, QueryOptions } from 'ofcore';
|
|
3
3
|
import { Purchase, PurchaseData } from '../models/Purchase';
|
|
4
4
|
import { PurchaseItem } from '../models/PurchaseItem';
|
|
5
|
+
import type { ServiceRuntimeOptions } from './runtimeSupport';
|
|
5
6
|
export interface PurchaseCart {
|
|
6
7
|
supplierId: string;
|
|
7
8
|
items: Array<{
|
|
@@ -77,17 +78,21 @@ export interface IPurchaseService {
|
|
|
77
78
|
/** Service implementation for Purchase operations. */
|
|
78
79
|
export declare class PurchaseService implements IPurchaseService {
|
|
79
80
|
private context;
|
|
81
|
+
private readonly _runtimeOptions;
|
|
80
82
|
private dbAdapter;
|
|
81
|
-
private
|
|
83
|
+
private changeQueue;
|
|
82
84
|
private docNumberPolicy;
|
|
83
85
|
private readonly defaultBaseCurrencyCode;
|
|
84
86
|
/**
|
|
85
87
|
* Initialize PurchaseService.
|
|
86
88
|
* @param context - PosCore context
|
|
87
89
|
*/
|
|
88
|
-
constructor(context: PosCore);
|
|
90
|
+
constructor(context: PosCore, _runtimeOptions?: Partial<ServiceRuntimeOptions>);
|
|
89
91
|
private roundCurrencyAmount;
|
|
90
92
|
private resolveCurrencySnapshot;
|
|
93
|
+
private toBaseQuantity;
|
|
94
|
+
private toBaseUnitCost;
|
|
95
|
+
private emitFinanceProjection;
|
|
91
96
|
private getCostingMethod;
|
|
92
97
|
private applyCostingPolicy;
|
|
93
98
|
/** Add new Purchase. */
|
|
@@ -23,7 +23,7 @@ export interface IReceivableService {
|
|
|
23
23
|
export declare class ReceivableService implements IReceivableService {
|
|
24
24
|
private context;
|
|
25
25
|
private dbAdapter;
|
|
26
|
-
private
|
|
26
|
+
private changeQueue;
|
|
27
27
|
/**
|
|
28
28
|
* Initialize ReceivableService.
|
|
29
29
|
* @param context - PosCore context
|
|
@@ -23,7 +23,7 @@ export interface IReportScheduleService {
|
|
|
23
23
|
export declare class ReportScheduleService implements IReportScheduleService {
|
|
24
24
|
private context;
|
|
25
25
|
private dbAdapter;
|
|
26
|
-
private
|
|
26
|
+
private changeQueue;
|
|
27
27
|
/**
|
|
28
28
|
* Initialize ReportScheduleService.
|
|
29
29
|
* @param context - PosCore context
|
|
@@ -198,7 +198,7 @@ export declare class ReportingService implements IReportingService {
|
|
|
198
198
|
private dbAdapter;
|
|
199
199
|
/**
|
|
200
200
|
* Inisialisasi layanan pelaporan.
|
|
201
|
-
* @param context - instance PosCore yang berisi registry
|
|
201
|
+
* @param context - instance PosCore yang berisi registry runtime.
|
|
202
202
|
*/
|
|
203
203
|
constructor(context: PosCore);
|
|
204
204
|
/**
|
|
@@ -23,7 +23,7 @@ export interface IReturnItemService {
|
|
|
23
23
|
export declare class ReturnItemService implements IReturnItemService {
|
|
24
24
|
private context;
|
|
25
25
|
private dbAdapter;
|
|
26
|
-
private
|
|
26
|
+
private changeQueue;
|
|
27
27
|
/**
|
|
28
28
|
* Initialize ReturnItemService.
|
|
29
29
|
* @param context - PosCore context
|
|
@@ -2,6 +2,7 @@ import { PosCore } from '../PosCore';
|
|
|
2
2
|
import { DbAdapter, QueryOptions } from 'ofcore';
|
|
3
3
|
import { Return, ReturnData } from '../models/Return';
|
|
4
4
|
import { ReturnType } from '../models/Return';
|
|
5
|
+
import type { ServiceRuntimeOptions } from './runtimeSupport';
|
|
5
6
|
export interface ProcessReturnInput {
|
|
6
7
|
/** saleId atau purchaseId – salah satu wajib diisi */
|
|
7
8
|
saleId?: string | null;
|
|
@@ -72,13 +73,14 @@ export interface IReturnService {
|
|
|
72
73
|
/** Service implementation for Return operations. */
|
|
73
74
|
export declare class ReturnService implements IReturnService {
|
|
74
75
|
private context;
|
|
76
|
+
private readonly _runtimeOptions;
|
|
75
77
|
private dbAdapter;
|
|
76
|
-
private
|
|
78
|
+
private changeQueue;
|
|
77
79
|
/**
|
|
78
80
|
* Initialize ReturnService.
|
|
79
81
|
* @param context - PosCore context
|
|
80
82
|
*/
|
|
81
|
-
constructor(context: PosCore);
|
|
83
|
+
constructor(context: PosCore, _runtimeOptions?: Partial<ServiceRuntimeOptions>);
|
|
82
84
|
/** Add new Return. */
|
|
83
85
|
addReturn(data: ReturnData, tx?: DbAdapter): Promise<Return>;
|
|
84
86
|
/** Update existing Return. */
|
|
@@ -101,6 +103,7 @@ export declare class ReturnService implements IReturnService {
|
|
|
101
103
|
private getFraudGuardPolicy;
|
|
102
104
|
private shouldTriggerFraudGuardForRefund;
|
|
103
105
|
private shouldTriggerFraudGuardForCancel;
|
|
106
|
+
private emitFinanceProjection;
|
|
104
107
|
processReturn(input: ProcessReturnInput): Promise<{
|
|
105
108
|
returnId: string;
|
|
106
109
|
queued: boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LoggerAdapter } from 'ofcore';
|
|
2
|
+
import type { PosCashAdjustmentAccountMapping, PosCashAdjustmentFinanceProjection, PosExpenseAccountMapping, PosExpenseFinanceProjection, PosPurchaseAccountMapping, PosPurchaseFinanceProjection, PosReturnAccountMapping, PosReturnFinanceProjection, PosSaleAccountMapping, PosSettlementAccountMapping, PosSettlementFinanceProjection, ScopedAccountMapping, ScopedPosSaleFinanceProjection } from '../finance/offinanceProjection';
|
|
3
|
+
export interface ServiceRuntimeOptions {
|
|
4
|
+
logger?: LoggerAdapter;
|
|
5
|
+
financeProjectionSink?: (projection: ScopedPosSaleFinanceProjection | PosPurchaseFinanceProjection | PosReturnFinanceProjection | PosExpenseFinanceProjection | PosSettlementFinanceProjection | PosCashAdjustmentFinanceProjection) => Promise<void> | void;
|
|
6
|
+
saleAccountMapping?: ScopedAccountMapping<PosSaleAccountMapping>;
|
|
7
|
+
purchaseAccountMapping?: ScopedAccountMapping<PosPurchaseAccountMapping>;
|
|
8
|
+
returnAccountMapping?: ScopedAccountMapping<PosReturnAccountMapping>;
|
|
9
|
+
expenseAccountMapping?: ScopedAccountMapping<PosExpenseAccountMapping>;
|
|
10
|
+
settlementAccountMapping?: ScopedAccountMapping<PosSettlementAccountMapping>;
|
|
11
|
+
cashAdjustmentAccountMapping?: ScopedAccountMapping<PosCashAdjustmentAccountMapping>;
|
|
12
|
+
}
|
|
@@ -23,7 +23,7 @@ export interface ISaleItemService {
|
|
|
23
23
|
export declare class SaleItemService implements ISaleItemService {
|
|
24
24
|
private context;
|
|
25
25
|
private dbAdapter;
|
|
26
|
-
private
|
|
26
|
+
private changeQueue;
|
|
27
27
|
/**
|
|
28
28
|
* Initialize SaleItemService.
|
|
29
29
|
* @param context - PosCore context
|
|
@@ -2,6 +2,7 @@ import { PosCore } from '../PosCore';
|
|
|
2
2
|
import { DbAdapter, QueryOptions } from 'ofcore';
|
|
3
3
|
import { Sale, SaleData } from '../models/Sale';
|
|
4
4
|
import { SaleItem } from '../models/SaleItem';
|
|
5
|
+
import type { ServiceRuntimeOptions } from './runtimeSupport';
|
|
5
6
|
/** Service interface for Sale operations. */
|
|
6
7
|
export interface ISaleService {
|
|
7
8
|
/** Add new Sale. */
|
|
@@ -70,21 +71,24 @@ export interface ISaleService {
|
|
|
70
71
|
/** Service implementation for Sale operations. */
|
|
71
72
|
export declare class SaleService implements ISaleService {
|
|
72
73
|
private context;
|
|
74
|
+
private readonly runtimeOptions;
|
|
73
75
|
private dbAdapter;
|
|
74
|
-
private
|
|
76
|
+
private changeQueue;
|
|
75
77
|
private docNumberPolicy;
|
|
76
78
|
private readonly defaultBaseCurrencyCode;
|
|
77
79
|
/**
|
|
78
80
|
* Initialize SaleService.
|
|
79
81
|
* @param context - PosCore context
|
|
80
82
|
*/
|
|
81
|
-
constructor(context: PosCore);
|
|
83
|
+
constructor(context: PosCore, runtimeOptions?: Partial<ServiceRuntimeOptions>);
|
|
82
84
|
private roundCurrencyAmount;
|
|
83
85
|
private resolveCurrencySnapshot;
|
|
84
86
|
private isExpiredLot;
|
|
85
87
|
private diffInDays;
|
|
86
88
|
private enforceTempoCustomerCreditPolicy;
|
|
87
89
|
private normalizeDocNo;
|
|
90
|
+
private toBaseQuantity;
|
|
91
|
+
private emitFinanceProjection;
|
|
88
92
|
getDuplicateDocumentNumbers(options?: {
|
|
89
93
|
dateFrom?: string;
|
|
90
94
|
dateTo?: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PosCore } from '../PosCore';
|
|
2
2
|
import { DbAdapter, QueryOptions } from 'ofcore';
|
|
3
3
|
import { Settlement, SettlementData } from '../models/Settlement';
|
|
4
|
+
import type { ServiceRuntimeOptions } from './runtimeSupport';
|
|
4
5
|
/** Service interface for Settlement operations. */
|
|
5
6
|
export interface ISettlementService {
|
|
6
7
|
/** Add new Settlement. */
|
|
@@ -32,14 +33,16 @@ export interface ISettlementService {
|
|
|
32
33
|
/** Service implementation for Settlement operations. */
|
|
33
34
|
export declare class SettlementService implements ISettlementService {
|
|
34
35
|
private context;
|
|
36
|
+
private readonly runtimeOptions;
|
|
35
37
|
private dbAdapter;
|
|
36
|
-
private
|
|
38
|
+
private changeQueue;
|
|
37
39
|
private runInTransaction;
|
|
38
40
|
/**
|
|
39
41
|
* Initialize SettlementService.
|
|
40
42
|
* @param context - PosCore context
|
|
41
43
|
*/
|
|
42
|
-
constructor(context: PosCore);
|
|
44
|
+
constructor(context: PosCore, runtimeOptions?: Partial<ServiceRuntimeOptions>);
|
|
45
|
+
private emitFinanceProjection;
|
|
43
46
|
/** Add new Settlement. */
|
|
44
47
|
addSettlement(data: SettlementData, tx?: DbAdapter): Promise<Settlement>;
|
|
45
48
|
/** Update existing Settlement. */
|
|
@@ -44,7 +44,7 @@ export interface IShiftService {
|
|
|
44
44
|
export declare class ShiftService implements IShiftService {
|
|
45
45
|
private context;
|
|
46
46
|
private dbAdapter;
|
|
47
|
-
private
|
|
47
|
+
private changeQueue;
|
|
48
48
|
/**
|
|
49
49
|
* Initialize ShiftService.
|
|
50
50
|
* @param context - PosCore context
|
|
@@ -23,7 +23,7 @@ export interface IStockAdjustmentService {
|
|
|
23
23
|
export declare class StockAdjustmentService implements IStockAdjustmentService {
|
|
24
24
|
private context;
|
|
25
25
|
private dbAdapter;
|
|
26
|
-
private
|
|
26
|
+
private changeQueue;
|
|
27
27
|
/**
|
|
28
28
|
* Initialize StockAdjustmentService.
|
|
29
29
|
* @param context - PosCore context
|
|
@@ -23,7 +23,7 @@ export interface IStockOpnameItemService {
|
|
|
23
23
|
export declare class StockOpnameItemService implements IStockOpnameItemService {
|
|
24
24
|
private context;
|
|
25
25
|
private dbAdapter;
|
|
26
|
-
private
|
|
26
|
+
private changeQueue;
|
|
27
27
|
/**
|
|
28
28
|
* Initialize StockOpnameItemService.
|
|
29
29
|
* @param context - PosCore context
|
|
@@ -25,7 +25,7 @@ export interface IStockOpnameService {
|
|
|
25
25
|
export declare class StockOpnameService implements IStockOpnameService {
|
|
26
26
|
private context;
|
|
27
27
|
private dbAdapter;
|
|
28
|
-
private
|
|
28
|
+
private changeQueue;
|
|
29
29
|
/**
|
|
30
30
|
* Initialize StockOpnameService.
|
|
31
31
|
* @param context - PosCore context
|
|
@@ -25,7 +25,7 @@ export interface ISupplierService {
|
|
|
25
25
|
export declare class SupplierService implements ISupplierService {
|
|
26
26
|
private context;
|
|
27
27
|
private dbAdapter;
|
|
28
|
-
private
|
|
28
|
+
private changeQueue;
|
|
29
29
|
/**
|
|
30
30
|
* Initialize SupplierService.
|
|
31
31
|
* @param context - PosCore context
|
|
@@ -23,7 +23,7 @@ export interface ITaxRateService {
|
|
|
23
23
|
export declare class TaxRateService implements ITaxRateService {
|
|
24
24
|
private context;
|
|
25
25
|
private dbAdapter;
|
|
26
|
-
private
|
|
26
|
+
private changeQueue;
|
|
27
27
|
/**
|
|
28
28
|
* Initialize TaxRateService.
|
|
29
29
|
* @param context - PosCore context
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PosCore } from '../PosCore';
|
|
2
2
|
import { DbAdapter, QueryOptions } from 'ofcore';
|
|
3
3
|
import { Transaction, TransactionData } from '../models/Transaction';
|
|
4
|
+
import type { ServiceRuntimeOptions } from './runtimeSupport';
|
|
4
5
|
/** Service interface for Transaction operations. */
|
|
5
6
|
export interface ITransactionService {
|
|
6
7
|
/** Add new Transaction. */
|
|
@@ -48,14 +49,16 @@ export interface ITransactionService {
|
|
|
48
49
|
/** Service implementation for Transaction operations. */
|
|
49
50
|
export declare class TransactionService implements ITransactionService {
|
|
50
51
|
private context;
|
|
52
|
+
private readonly runtimeOptions;
|
|
51
53
|
private dbAdapter;
|
|
52
|
-
private
|
|
54
|
+
private changeQueue;
|
|
53
55
|
private readonly allowedReferenceTypes;
|
|
54
56
|
/**
|
|
55
57
|
* Initialize TransactionService.
|
|
56
58
|
* @param context - PosCore context
|
|
57
59
|
*/
|
|
58
|
-
constructor(context: PosCore);
|
|
60
|
+
constructor(context: PosCore, runtimeOptions?: Partial<ServiceRuntimeOptions>);
|
|
61
|
+
private emitCashAdjustmentFinanceProjection;
|
|
59
62
|
private getIdempotentTransaction;
|
|
60
63
|
private saveIdempotencyMarker;
|
|
61
64
|
private getActorId;
|
|
@@ -68,7 +68,6 @@ export declare class UIProductService implements IUIProductService {
|
|
|
68
68
|
private readonly dbAdapter;
|
|
69
69
|
private readonly productService;
|
|
70
70
|
private readonly bomService;
|
|
71
|
-
private readonly syncStore?;
|
|
72
71
|
/**
|
|
73
72
|
* Membuat instance layanan UI produk.
|
|
74
73
|
* @param context Konteks PosCore dengan dependensi yang diperlukan.
|
|
@@ -1,44 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Bridge file for RFC extraction phase.
|
|
3
|
+
*
|
|
4
|
+
* Source of truth for generic storage contract/defaults is `ofcore`.
|
|
5
|
+
* Shared-core keeps this path for backward import compatibility.
|
|
3
6
|
*/
|
|
4
|
-
import {
|
|
7
|
+
import { MemoryStorageAdapter } from 'ofcore';
|
|
8
|
+
export type { StorageAdapter } from 'ofcore';
|
|
5
9
|
/**
|
|
6
|
-
*
|
|
10
|
+
* Backward-compatible alias for previous shared-core name.
|
|
7
11
|
*/
|
|
8
|
-
export
|
|
9
|
-
/**
|
|
10
|
-
* Mengambil nilai berdasarkan key.
|
|
11
|
-
* @param key Kunci item
|
|
12
|
-
* @returns Promise atau nilai string|null
|
|
13
|
-
*/
|
|
14
|
-
getItem(key: string): Promise<string | null> | string | null;
|
|
15
|
-
/**
|
|
16
|
-
* Menyimpan nilai dengan key tertentu.
|
|
17
|
-
* @param key Kunci item
|
|
18
|
-
* @param value Nilai string yang akan disimpan
|
|
19
|
-
*/
|
|
20
|
-
setItem(key: string, value: string): Promise<void> | void;
|
|
21
|
-
/**
|
|
22
|
-
* Menghapus item berdasarkan key.
|
|
23
|
-
* @param key Kunci item yang akan dihapus
|
|
24
|
-
*/
|
|
25
|
-
removeItem(key: string): Promise<void> | void;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Adapter penyimpanan memori untuk testing atau demo.
|
|
29
|
-
*/
|
|
30
|
-
export declare class MemoryStorage implements StorageAdapter {
|
|
31
|
-
private context;
|
|
32
|
-
private map;
|
|
33
|
-
/**
|
|
34
|
-
* Membuat instance MemoryStorage.
|
|
35
|
-
* @param context PosCore sebagai konteks (opsional)
|
|
36
|
-
*/
|
|
37
|
-
constructor(context: PosCore);
|
|
38
|
-
/** {@inheritDoc StorageAdapter.getItem} */
|
|
39
|
-
getItem(key: string): string | null;
|
|
40
|
-
/** {@inheritDoc StorageAdapter.setItem} */
|
|
41
|
-
setItem(key: string, value: string): void;
|
|
42
|
-
/** {@inheritDoc StorageAdapter.removeItem} */
|
|
43
|
-
removeItem(key: string): void;
|
|
12
|
+
export declare class MemoryStorage extends MemoryStorageAdapter {
|
|
44
13
|
}
|
|
@@ -40,6 +40,16 @@ export interface ISyncService {
|
|
|
40
40
|
*/
|
|
41
41
|
syncLoop(): Promise<void>;
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Implementasi sinkronisasi no-op untuk mode host-managed sync orchestration.
|
|
45
|
+
* Dipakai saat host app ingin menyerahkan push/pull ke ofsync-shared-core.
|
|
46
|
+
*/
|
|
47
|
+
export declare class NoopSyncService implements ISyncService {
|
|
48
|
+
backoff<T>(fn: () => Promise<T>): Promise<T>;
|
|
49
|
+
applyChanges(): Promise<void>;
|
|
50
|
+
syncWithErp(): Promise<void>;
|
|
51
|
+
syncLoop(): Promise<void>;
|
|
52
|
+
}
|
|
43
53
|
/**
|
|
44
54
|
* Implementasi layanan sinkronisasi.
|
|
45
55
|
*/
|
|
@@ -53,11 +63,17 @@ export declare class SyncService {
|
|
|
53
63
|
private unsubscribeStore?;
|
|
54
64
|
private readonly onDataChanged;
|
|
55
65
|
private lastAlertAtByCode;
|
|
66
|
+
private started;
|
|
56
67
|
/**
|
|
57
68
|
* Membuat instance SyncService.
|
|
58
69
|
* @param context Konteks PosCore aplikasi
|
|
59
70
|
*/
|
|
60
71
|
constructor(context: PosCore);
|
|
72
|
+
/**
|
|
73
|
+
* Aktifkan orchestration internal (debounce queue, socket trigger, periodic fallback).
|
|
74
|
+
* Idempotent: aman dipanggil berkali-kali.
|
|
75
|
+
*/
|
|
76
|
+
start(): void;
|
|
61
77
|
private normalizeOutgoingChange;
|
|
62
78
|
private getRemoteTimestamp;
|
|
63
79
|
private getConflictResolutionStrategy;
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ofpos-shared-core",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Offline-first POS
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
|
+
"description": "Offline-first POS shared-core (domain and integration runtime) for of* host apps; platform and database agnostic.",
|
|
5
|
+
"private": false,
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Agus Made",
|
|
8
|
+
"email": "krisnaparta@gmail.com"
|
|
9
|
+
},
|
|
5
10
|
"main": "dist/index.cjs.js",
|
|
6
11
|
"module": "dist/index.esm.js",
|
|
7
12
|
"browser": "dist/index.browser.mjs",
|
|
@@ -31,29 +36,44 @@
|
|
|
31
36
|
"verify:ofcore-spike": "node ./scripts/verify-ofcore-spike.js",
|
|
32
37
|
"verify:ofcore-bridges": "node ./scripts/verify-ofcore-bridges.js",
|
|
33
38
|
"verify:no-internal-bridge-imports": "node ./scripts/verify-no-internal-bridge-imports.js",
|
|
39
|
+
"verify:ofauth-coupling": "node ./scripts/verify-ofauth-coupling.js",
|
|
34
40
|
"verify:governance": "node ./scripts/verify-governance-transport.js",
|
|
35
41
|
"verify:governance:negative": "node ./scripts/verify-governance-transport-negative.js",
|
|
36
42
|
"verify:poscore-runtime-bridge": "node ./scripts/verify-poscore-runtime-bridge.js",
|
|
37
43
|
"verify:poscore-overrides": "node ./scripts/verify-poscore-overrides.js",
|
|
44
|
+
"verify:auth-bridge-policy-mode": "node ./scripts/verify-auth-bridge-policy-mode.js",
|
|
45
|
+
"verify:host-managed-sync-mode": "node ./scripts/verify-host-managed-sync-mode.js",
|
|
46
|
+
"verify:sync-boundary": "node ./scripts/verify-sync-boundary.js",
|
|
38
47
|
"audit:schema": "node ./scripts/schema-audit.js",
|
|
39
48
|
"docs:check-links": "bash ./scripts/check-docs-links.sh",
|
|
40
|
-
"ci:check": "npm run lint && npm test -- --runInBand && npm run build && npm run verify:release-discipline && npm run verify:ofcore-bridges && npm run verify:no-internal-bridge-imports && npm run verify:governance && npm run verify:governance:negative && npm run verify:poscore-runtime-bridge && npm run verify:poscore-overrides && npm run docs:check-links",
|
|
49
|
+
"ci:check": "npm run lint && npm test -- --runInBand && npm run build && npm run verify:release-discipline && npm run verify:ofcore-bridges && npm run verify:no-internal-bridge-imports && npm run verify:ofauth-coupling && npm run verify:governance && npm run verify:governance:negative && npm run verify:poscore-runtime-bridge && npm run verify:poscore-overrides && npm run verify:auth-bridge-policy-mode && npm run verify:host-managed-sync-mode && npm run verify:sync-boundary && npm run docs:check-links",
|
|
41
50
|
"test:watch": "jest --watch",
|
|
42
51
|
"docs": "typedoc src/index.ts --out tsdocs",
|
|
52
|
+
"prepublishOnly": "npm run ci:check",
|
|
43
53
|
"prepack": "npm run build"
|
|
44
54
|
},
|
|
45
55
|
"repository": {
|
|
46
56
|
"type": "git",
|
|
47
|
-
"url": "git+https://
|
|
57
|
+
"url": "git+https://gitlab.com/rintisan/inti/ofpos-shared-core.git"
|
|
48
58
|
},
|
|
49
|
-
"author": "Agus Made <krisnaparta@gmail.com>",
|
|
50
59
|
"license": "MIT",
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public"
|
|
62
|
+
},
|
|
51
63
|
"files": [
|
|
52
64
|
"dist"
|
|
53
65
|
],
|
|
54
66
|
"dependencies": {
|
|
55
|
-
"ofcore": "0.
|
|
56
|
-
"
|
|
67
|
+
"ofcore": "0.2.0-alpha.0",
|
|
68
|
+
"offinance-shared-core": "0.1.0-alpha.1"
|
|
69
|
+
},
|
|
70
|
+
"peerDependencies": {
|
|
71
|
+
"ofauth-shared-core": "0.2.0-alpha.0"
|
|
72
|
+
},
|
|
73
|
+
"peerDependenciesMeta": {
|
|
74
|
+
"ofauth-shared-core": {
|
|
75
|
+
"optional": true
|
|
76
|
+
}
|
|
57
77
|
},
|
|
58
78
|
"devDependencies": {
|
|
59
79
|
"@types/crypto-js": "^4.2.2",
|
|
@@ -70,6 +90,7 @@
|
|
|
70
90
|
"jest": "^30.2.0",
|
|
71
91
|
"jest-html-reporters": "^3.1.7",
|
|
72
92
|
"mitt": "^3.0.1",
|
|
93
|
+
"ofauth-shared-core": "0.2.0-alpha.0",
|
|
73
94
|
"react": "^19.2.0",
|
|
74
95
|
"reflect-metadata": "^0.2.2",
|
|
75
96
|
"rimraf": "^6.0.1",
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-memory implementation of DbAdapter for testing and development.
|
|
3
|
-
* Fully compliant with the latest DbAdapter interface.
|
|
4
|
-
*/
|
|
5
|
-
import { DbAdapter, TableSchema, ColumnDefinition, DbSchema, QueryOptions, LiteralValue } from './DbAdapter';
|
|
6
|
-
export declare class InMemoryDbAdapter implements DbAdapter {
|
|
7
|
-
schema: DbSchema;
|
|
8
|
-
private data;
|
|
9
|
-
/**
|
|
10
|
-
* Initialize with a full schema (e.g., from `schemas`).
|
|
11
|
-
*/
|
|
12
|
-
setUpWithSchema(schema: DbSchema): Promise<void>;
|
|
13
|
-
/**
|
|
14
|
-
* Normalize value for comparison (handles Date, boolean, etc.)
|
|
15
|
-
*/
|
|
16
|
-
private normalizeForComparison;
|
|
17
|
-
/**
|
|
18
|
-
* Evaluate a ValueExpression against a record (and joined records).
|
|
19
|
-
* @param record Record from main table
|
|
20
|
-
* @param joinedRecords Map of alias → record (for joins)
|
|
21
|
-
* @param expr ValueExpression to evaluate
|
|
22
|
-
* @param mainAlias Main table alias (default: 't0')
|
|
23
|
-
*/
|
|
24
|
-
private evalValueExpr;
|
|
25
|
-
private buildFieldCondition;
|
|
26
|
-
/**
|
|
27
|
-
* Recursively evaluate FilterExpression.
|
|
28
|
-
*/
|
|
29
|
-
private matchFilterExpression;
|
|
30
|
-
/**
|
|
31
|
-
* Simulate JOINs by pre-matching records (for testing only).
|
|
32
|
-
* Limited to one-to-many/many-to-one; no many-to-many or complex conditions.
|
|
33
|
-
*/
|
|
34
|
-
private simulateJoins;
|
|
35
|
-
/**
|
|
36
|
-
* Extract field from record (handles alias.field and string field).
|
|
37
|
-
*/
|
|
38
|
-
private extractField;
|
|
39
|
-
private extractAggregateField;
|
|
40
|
-
getSchemaVersion(): Promise<number>;
|
|
41
|
-
setSchemaVersion(version: number): Promise<void>;
|
|
42
|
-
addTable(table: TableSchema): Promise<void>;
|
|
43
|
-
addColumn(_table: string, _column: ColumnDefinition): Promise<void>;
|
|
44
|
-
get<T>(table: string, idOrOptions: string | QueryOptions): Promise<T | null>;
|
|
45
|
-
query<T>(table: string, options?: QueryOptions): Promise<T[]>;
|
|
46
|
-
create<T>(table: string, data: Partial<Record<string, LiteralValue>> & {
|
|
47
|
-
id: string;
|
|
48
|
-
}): Promise<T>;
|
|
49
|
-
update<T>(table: string, id: string, updates: Partial<Record<string, LiteralValue>>): Promise<T>;
|
|
50
|
-
delete(table: string, id: string): Promise<void>;
|
|
51
|
-
bulkCreate<T>(table: string, rows: Array<Partial<Record<string, LiteralValue>> & {
|
|
52
|
-
id: string;
|
|
53
|
-
}>): Promise<T[]>;
|
|
54
|
-
bulkUpdate<T>(table: string, rows: Array<{
|
|
55
|
-
id: string;
|
|
56
|
-
updates: Partial<Record<string, LiteralValue>>;
|
|
57
|
-
}>): Promise<T[]>;
|
|
58
|
-
private transactionDepth;
|
|
59
|
-
private snapshots;
|
|
60
|
-
/**
|
|
61
|
-
* Simpan snapshot seluruh database (shallow copy cukup karena data immutable dalam transaksi)
|
|
62
|
-
*/
|
|
63
|
-
private takeSnapshot;
|
|
64
|
-
transaction<T>(callback: (tx: this) => Promise<T>): Promise<T>;
|
|
65
|
-
}
|