cry-synced-db-client 0.1.119 → 0.1.120
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.js
CHANGED
|
@@ -1087,7 +1087,7 @@ var ConnectionManager = class {
|
|
|
1087
1087
|
// Private Methods
|
|
1088
1088
|
// ============================================================
|
|
1089
1089
|
async tryGoOnline() {
|
|
1090
|
-
var _a, _b, _c, _d;
|
|
1090
|
+
var _a, _b, _c, _d, _e;
|
|
1091
1091
|
if (this.forcedOffline) {
|
|
1092
1092
|
return;
|
|
1093
1093
|
}
|
|
@@ -1097,13 +1097,14 @@ var ConnectionManager = class {
|
|
|
1097
1097
|
"ping"
|
|
1098
1098
|
);
|
|
1099
1099
|
if (!pingResult) {
|
|
1100
|
-
|
|
1100
|
+
const url = (_a = this.restInterface.endpoint) != null ? _a : "unknown";
|
|
1101
|
+
console.warn(`Ping to ${url} failed - staying offline`);
|
|
1101
1102
|
return;
|
|
1102
1103
|
}
|
|
1103
1104
|
const wasOffline = !this.online;
|
|
1104
1105
|
this.online = true;
|
|
1105
1106
|
if (wasOffline) {
|
|
1106
|
-
(
|
|
1107
|
+
(_c = (_b = this.callbacks).onOnlineStatusChange) == null ? void 0 : _c.call(_b, true);
|
|
1107
1108
|
if (!this.deps.isLeader()) {
|
|
1108
1109
|
this.deps.tryBecomeLeader();
|
|
1109
1110
|
}
|
|
@@ -1115,7 +1116,7 @@ var ConnectionManager = class {
|
|
|
1115
1116
|
const wasOnline = this.online;
|
|
1116
1117
|
this.online = false;
|
|
1117
1118
|
if (wasOnline) {
|
|
1118
|
-
(
|
|
1119
|
+
(_e = (_d = this.callbacks).onOnlineStatusChange) == null ? void 0 : _e.call(_d, false);
|
|
1119
1120
|
}
|
|
1120
1121
|
}
|
|
1121
1122
|
}
|
|
@@ -3691,7 +3692,7 @@ var SyncedDb = class _SyncedDb {
|
|
|
3691
3692
|
}
|
|
3692
3693
|
// ==================== Lifecycle ====================
|
|
3693
3694
|
async init() {
|
|
3694
|
-
var _a, _b;
|
|
3695
|
+
var _a, _b, _c, _d;
|
|
3695
3696
|
if (this.initialized) return;
|
|
3696
3697
|
if (typeof localStorage === "undefined") {
|
|
3697
3698
|
this.connectionManager.reportInfrastructureError(
|
|
@@ -3741,10 +3742,14 @@ var SyncedDb = class _SyncedDb {
|
|
|
3741
3742
|
);
|
|
3742
3743
|
try {
|
|
3743
3744
|
await this.serverUpdateNotifier.connect();
|
|
3745
|
+
const ep = (_c = this.serverUpdateNotifier.endpoint) != null ? _c : "unknown";
|
|
3746
|
+
console.log(`SyncedDb: ebus-proxy connected to ${ep}`);
|
|
3744
3747
|
} catch (err) {
|
|
3748
|
+
const ep = (_d = this.serverUpdateNotifier.endpoint) != null ? _d : "unknown";
|
|
3749
|
+
console.warn(`SyncedDb: ebus-proxy connection to ${ep} failed`);
|
|
3745
3750
|
this.connectionManager.reportInfrastructureError(
|
|
3746
3751
|
"WEBSOCKET_CONNECTION_FAILED",
|
|
3747
|
-
|
|
3752
|
+
`WebSocket connection to ${ep} failed during initialization`,
|
|
3748
3753
|
err instanceof Error ? err : new Error(String(err))
|
|
3749
3754
|
);
|
|
3750
3755
|
}
|
|
@@ -7523,6 +7528,7 @@ var Ebus2ProxyServerUpdateNotifier = class {
|
|
|
7523
7528
|
this.forcedOffline = false;
|
|
7524
7529
|
this.subscribedChannels = /* @__PURE__ */ new Set();
|
|
7525
7530
|
var _a, _b, _c, _d, _e;
|
|
7531
|
+
this.endpoint = config.wsUrl;
|
|
7526
7532
|
this.wsUrl = config.wsUrl;
|
|
7527
7533
|
this.dbName = config.dbName;
|
|
7528
7534
|
this.collections = config.collections;
|
|
@@ -7670,6 +7676,9 @@ var Ebus2ProxyServerUpdateNotifier = class {
|
|
|
7670
7676
|
this.connected = true;
|
|
7671
7677
|
this.reconnectAttempt = 0;
|
|
7672
7678
|
this.currentReconnectDelay = this.reconnectDelayMs;
|
|
7679
|
+
console.log(
|
|
7680
|
+
`Ebus2Proxy connected to ${this.wsUrl} (db: ${this.dbName})`
|
|
7681
|
+
);
|
|
7673
7682
|
this.sendSubscribe(`db/${this.dbName}`);
|
|
7674
7683
|
if (this.subscribeServices) {
|
|
7675
7684
|
this.sendSubscribe("ebus/services");
|
|
@@ -61,7 +61,7 @@ export interface RestProxyConfig {
|
|
|
61
61
|
* complex types (Date, Map, Set, RegExp, etc.)
|
|
62
62
|
*/
|
|
63
63
|
export declare class RestProxy implements I_RestInterface {
|
|
64
|
-
|
|
64
|
+
readonly endpoint: string;
|
|
65
65
|
private tenant;
|
|
66
66
|
private apiKey?;
|
|
67
67
|
private defaultTimeoutMs;
|
|
@@ -65,6 +65,8 @@ export type CollectionUpdateRequest<T> = {
|
|
|
65
65
|
* Vsebuje samo metode, potrebne za sinhronizacijo
|
|
66
66
|
*/
|
|
67
67
|
export interface I_RestInterface {
|
|
68
|
+
/** Server endpoint URL (for diagnostics/logging). */
|
|
69
|
+
readonly endpoint?: string;
|
|
68
70
|
/** Preveri povezljivost s serverjem - vrne true če je server dosegljiv */
|
|
69
71
|
ping(): Promise<boolean>;
|
|
70
72
|
/** Fetch a single item by ID, returns null if not found */
|
|
@@ -20,6 +20,8 @@ export interface ServerUpdateNotifierCallbacks {
|
|
|
20
20
|
* Implementacija je odvisna od transporta (WebSocket, SSE, polling, etc.)
|
|
21
21
|
*/
|
|
22
22
|
export interface I_ServerUpdateNotifier {
|
|
23
|
+
/** Server/WebSocket endpoint URL (for diagnostics/logging). */
|
|
24
|
+
readonly endpoint?: string;
|
|
23
25
|
/**
|
|
24
26
|
* Registriraj callback za prejemanje update notifikacij
|
|
25
27
|
* @param callback Funkcija, ki se pokliče ob vsaki notifikaciji
|