@a-cube-io/ereceipts-js-sdk 2.0.4 → 2.0.6
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/index.cjs.js +50 -14
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.esm.js +50 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/index.native.js +50 -14
- package/dist/index.native.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -2197,7 +2197,7 @@ class AuthStrategy {
|
|
|
2197
2197
|
return url.includes('/mf1/notifications');
|
|
2198
2198
|
}
|
|
2199
2199
|
isTelemetryEndpoint(url) {
|
|
2200
|
-
return !!url.match(/\/mf1\/
|
|
2200
|
+
return !!url.match(/\/mf1\/pems\/[^/]+\/telemetry/);
|
|
2201
2201
|
}
|
|
2202
2202
|
}
|
|
2203
2203
|
|
|
@@ -6328,7 +6328,7 @@ class ReceiptRepositoryImpl {
|
|
|
6328
6328
|
}
|
|
6329
6329
|
async findAll(params) {
|
|
6330
6330
|
const queryParams = ReceiptMapper.toListParams(params);
|
|
6331
|
-
const response = await this.http.get(`/mf1/
|
|
6331
|
+
const response = await this.http.get(`/mf1/pems/${params.serialNumber}/receipts`, { params: queryParams });
|
|
6332
6332
|
return ReceiptMapper.pageFromApi(response.data);
|
|
6333
6333
|
}
|
|
6334
6334
|
async getDetails(receiptUuid, format) {
|
|
@@ -6626,11 +6626,11 @@ class PointOfSaleRepositoryImpl {
|
|
|
6626
6626
|
this.http = http;
|
|
6627
6627
|
}
|
|
6628
6628
|
async findById(serialNumber) {
|
|
6629
|
-
const response = await this.http.get(`/mf1/
|
|
6629
|
+
const response = await this.http.get(`/mf1/pems/${serialNumber}`);
|
|
6630
6630
|
return PointOfSaleMapper.fromDetailedApiOutput(response.data);
|
|
6631
6631
|
}
|
|
6632
6632
|
async findAll(params) {
|
|
6633
|
-
const response = await this.http.get('/mf1/
|
|
6633
|
+
const response = await this.http.get('/mf1/pems', {
|
|
6634
6634
|
params: {
|
|
6635
6635
|
status: params?.status,
|
|
6636
6636
|
page: params?.page,
|
|
@@ -6641,17 +6641,17 @@ class PointOfSaleRepositoryImpl {
|
|
|
6641
6641
|
}
|
|
6642
6642
|
async activate(serialNumber, input) {
|
|
6643
6643
|
const apiInput = PointOfSaleMapper.toActivationApiInput(input);
|
|
6644
|
-
await this.http.post(`/mf1/
|
|
6644
|
+
await this.http.post(`/mf1/pems/${serialNumber}/activation`, apiInput);
|
|
6645
6645
|
}
|
|
6646
6646
|
async closeJournal(serialNumber) {
|
|
6647
|
-
await this.http.post(`/mf1/
|
|
6647
|
+
await this.http.post(`/mf1/pems/${serialNumber}/close`);
|
|
6648
6648
|
}
|
|
6649
6649
|
async createInactivity(serialNumber) {
|
|
6650
|
-
await this.http.post(`/mf1/
|
|
6650
|
+
await this.http.post(`/mf1/pems/${serialNumber}/inactivity`);
|
|
6651
6651
|
}
|
|
6652
6652
|
async communicateOffline(serialNumber, input) {
|
|
6653
6653
|
const apiInput = PointOfSaleMapper.toOfflineApiInput(input);
|
|
6654
|
-
await this.http.post(`/mf1/
|
|
6654
|
+
await this.http.post(`/mf1/pems/${serialNumber}/communicate-offline`, apiInput);
|
|
6655
6655
|
}
|
|
6656
6656
|
}
|
|
6657
6657
|
|
|
@@ -6770,19 +6770,19 @@ class PemRepositoryImpl {
|
|
|
6770
6770
|
}
|
|
6771
6771
|
async create(input) {
|
|
6772
6772
|
const apiInput = PemMapper.toCreateApiInput(input);
|
|
6773
|
-
const response = await this.http.post('/mf2/
|
|
6773
|
+
const response = await this.http.post('/mf2/pems', apiInput);
|
|
6774
6774
|
return PemMapper.fromCreateApiOutput(response.data);
|
|
6775
6775
|
}
|
|
6776
6776
|
async findBySerialNumber(serialNumber) {
|
|
6777
|
-
const response = await this.http.get(`/mf2/
|
|
6777
|
+
const response = await this.http.get(`/mf2/pems/${serialNumber}`);
|
|
6778
6778
|
return PemMapper.fromPointOfSaleMf2ApiOutput(response.data);
|
|
6779
6779
|
}
|
|
6780
6780
|
async findAllByMerchant(merchantUuid, page) {
|
|
6781
|
-
const response = await this.http.get(`/mf2/merchants/${merchantUuid}/
|
|
6781
|
+
const response = await this.http.get(`/mf2/merchants/${merchantUuid}/pems`, { params: { page } });
|
|
6782
6782
|
return PemMapper.pageFromApi(response.data);
|
|
6783
6783
|
}
|
|
6784
6784
|
async getCertificates(serialNumber) {
|
|
6785
|
-
const response = await this.http.get(`/mf2/
|
|
6785
|
+
const response = await this.http.get(`/mf2/pems/${serialNumber}/certificates`);
|
|
6786
6786
|
return PemMapper.fromCertificatesApiOutput(response.data);
|
|
6787
6787
|
}
|
|
6788
6788
|
}
|
|
@@ -7093,7 +7093,7 @@ class TelemetryRepositoryImpl {
|
|
|
7093
7093
|
this.http = http;
|
|
7094
7094
|
}
|
|
7095
7095
|
async getTelemetry(pemId) {
|
|
7096
|
-
const response = await this.http.get(`/mf1/
|
|
7096
|
+
const response = await this.http.get(`/mf1/pems/${pemId}/telemetry`);
|
|
7097
7097
|
return TelemetryMapper.fromApiOutput(response.data);
|
|
7098
7098
|
}
|
|
7099
7099
|
}
|
|
@@ -8724,6 +8724,35 @@ class SDKManager {
|
|
|
8724
8724
|
this.telemetryService = null;
|
|
8725
8725
|
this.appStateService = null;
|
|
8726
8726
|
this.isInitialized = false;
|
|
8727
|
+
this.isPollingActive = false;
|
|
8728
|
+
/**
|
|
8729
|
+
* Handle user state changes (login/logout/token expiration)
|
|
8730
|
+
* Manages polling lifecycle based on user role
|
|
8731
|
+
*/
|
|
8732
|
+
this.handleUserChanged = async (user) => {
|
|
8733
|
+
// Always call user's event handler first
|
|
8734
|
+
this.events?.onUserChanged?.(user);
|
|
8735
|
+
if (!this.isInitialized)
|
|
8736
|
+
return;
|
|
8737
|
+
if (user) {
|
|
8738
|
+
// User logged in - check role and start polling if allowed
|
|
8739
|
+
const canPoll = hasAnyRole(user.roles, ['ROLE_MERCHANT', 'ROLE_CASHIER']);
|
|
8740
|
+
if (canPoll && !this.isPollingActive) {
|
|
8741
|
+
this.notificationService?.startPolling();
|
|
8742
|
+
await this.startTelemetryPollingAuto();
|
|
8743
|
+
this.isPollingActive = true;
|
|
8744
|
+
}
|
|
8745
|
+
}
|
|
8746
|
+
else {
|
|
8747
|
+
// User logged out or token expired - stop polling
|
|
8748
|
+
if (this.isPollingActive) {
|
|
8749
|
+
this.notificationService?.stopPolling();
|
|
8750
|
+
this.telemetryService?.stopPolling();
|
|
8751
|
+
this.telemetryService?.clearTelemetry();
|
|
8752
|
+
this.isPollingActive = false;
|
|
8753
|
+
}
|
|
8754
|
+
}
|
|
8755
|
+
};
|
|
8727
8756
|
}
|
|
8728
8757
|
/**
|
|
8729
8758
|
* Configure the SDKManager singleton
|
|
@@ -8767,7 +8796,12 @@ class SDKManager {
|
|
|
8767
8796
|
async initialize() {
|
|
8768
8797
|
if (this.isInitialized)
|
|
8769
8798
|
return;
|
|
8770
|
-
|
|
8799
|
+
// Wrap events to intercept onUserChanged for polling lifecycle management
|
|
8800
|
+
const wrappedEvents = {
|
|
8801
|
+
...this.events,
|
|
8802
|
+
onUserChanged: this.handleUserChanged,
|
|
8803
|
+
};
|
|
8804
|
+
this.sdk = new ACubeSDK(this.config, this.adapters, wrappedEvents);
|
|
8771
8805
|
await this.sdk.initialize();
|
|
8772
8806
|
const adaptersRef = this.sdk.getAdapters();
|
|
8773
8807
|
if (!adaptersRef) {
|
|
@@ -8797,6 +8831,7 @@ class SDKManager {
|
|
|
8797
8831
|
if (canPoll) {
|
|
8798
8832
|
this.notificationService.startPolling();
|
|
8799
8833
|
await this.startTelemetryPollingAuto();
|
|
8834
|
+
this.isPollingActive = true;
|
|
8800
8835
|
}
|
|
8801
8836
|
// AppStateService remains active for all users (handles OFFLINE network state)
|
|
8802
8837
|
}
|
|
@@ -8950,6 +8985,7 @@ class SDKManager {
|
|
|
8950
8985
|
this.appStateService = null;
|
|
8951
8986
|
this.sdk = null;
|
|
8952
8987
|
this.isInitialized = false;
|
|
8988
|
+
this.isPollingActive = false;
|
|
8953
8989
|
}
|
|
8954
8990
|
ensureInitialized() {
|
|
8955
8991
|
if (!this.isInitialized) {
|