@dvina/sdk 4.0.221 → 4.0.230
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/adapters/angular/index.cjs +4 -4
- package/dist/adapters/angular/index.d.cts +2 -2
- package/dist/adapters/angular/index.d.ts +2 -2
- package/dist/adapters/angular/index.js +2 -2
- package/dist/billing/index.cjs +5 -5
- package/dist/billing/index.js +1 -1
- package/dist/{chunk-I7HS5CQ7.js → chunk-4IJ3Z2SR.js} +164 -12
- package/dist/chunk-4IJ3Z2SR.js.map +1 -0
- package/dist/{chunk-VDPZQ5F3.cjs → chunk-4Y42KQCH.cjs} +22 -68
- package/dist/chunk-4Y42KQCH.cjs.map +1 -0
- package/dist/{chunk-LNQAR2M2.cjs → chunk-AU5C7Y4P.cjs} +186 -34
- package/dist/chunk-AU5C7Y4P.cjs.map +1 -0
- package/dist/{chunk-ZGGY4WK7.js → chunk-RVXRT5EI.js} +22 -68
- package/dist/chunk-RVXRT5EI.js.map +1 -0
- package/dist/{client-BAich_Hx.d.cts → client-DI2pYavC.d.cts} +1 -1
- package/dist/{client-DW2pRGde.d.ts → client-DRZeTTgS.d.ts} +1 -1
- package/dist/{index-DF59UYzN.d.cts → index-Bwe8KY0Z.d.cts} +1 -1
- package/dist/{index-Bld5-Yr1.d.ts → index-DqQrAjp3.d.ts} +1 -1
- package/dist/index.cjs +390 -390
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +2 -2
- package/dist/pagination/index.d.cts +2 -2
- package/dist/pagination/index.d.ts +2 -2
- package/dist/{sync-engine-CZ0U9XBy.d.ts → sync-engine-CYIG5amb.d.ts} +5 -2
- package/dist/{sync-engine-DXESBFX0.d.cts → sync-engine-DPVgCDPC.d.cts} +5 -2
- package/package.json +1 -1
- package/dist/chunk-I7HS5CQ7.js.map +0 -1
- package/dist/chunk-LNQAR2M2.cjs.map +0 -1
- package/dist/chunk-VDPZQ5F3.cjs.map +0 -1
- package/dist/chunk-ZGGY4WK7.js.map +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var chunk342BFYZZ_cjs = require('./chunk-342BFYZZ.cjs');
|
|
4
4
|
var chunkUELAE75E_cjs = require('./chunk-UELAE75E.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunk4Y42KQCH_cjs = require('./chunk-4Y42KQCH.cjs');
|
|
6
6
|
var chunkKV5SP7RP_cjs = require('./chunk-KV5SP7RP.cjs');
|
|
7
7
|
var chunk5G4TDB2H_cjs = require('./chunk-5G4TDB2H.cjs');
|
|
8
8
|
var chunkDZUJEN5N_cjs = require('./chunk-DZUJEN5N.cjs');
|
|
@@ -6037,6 +6037,7 @@ var INITIAL_RECONNECT_DELAY_MS = 1e3;
|
|
|
6037
6037
|
var MAX_RECONNECT_DELAY_MS = 3e4;
|
|
6038
6038
|
var RECONNECT_BACKOFF_MULTIPLIER = 2;
|
|
6039
6039
|
var MAX_CONSECUTIVE_AUTH_FAILURES = 3;
|
|
6040
|
+
var STALE_CONNECTION_TIMEOUT_MS = 35e3;
|
|
6040
6041
|
var AuthChatStreamError = class extends Error {
|
|
6041
6042
|
constructor(status) {
|
|
6042
6043
|
super(`Chat stream auth failed: ${status}`);
|
|
@@ -6057,6 +6058,8 @@ var ChatStreamConnection = class {
|
|
|
6057
6058
|
needsForceRefresh = false;
|
|
6058
6059
|
reconnectDelay = INITIAL_RECONNECT_DELAY_MS;
|
|
6059
6060
|
reconnectTimer;
|
|
6061
|
+
staleReconnectRequested = false;
|
|
6062
|
+
staleTimer;
|
|
6060
6063
|
shouldReconnect = false;
|
|
6061
6064
|
subscribers = /* @__PURE__ */ new Set();
|
|
6062
6065
|
addSubscriber(subscriber) {
|
|
@@ -6092,6 +6095,8 @@ var ChatStreamConnection = class {
|
|
|
6092
6095
|
close(error) {
|
|
6093
6096
|
this.shouldReconnect = false;
|
|
6094
6097
|
this.destroyed = true;
|
|
6098
|
+
this.staleReconnectRequested = false;
|
|
6099
|
+
this.clearStaleTimer();
|
|
6095
6100
|
if (this.reconnectTimer) {
|
|
6096
6101
|
clearTimeout(this.reconnectTimer);
|
|
6097
6102
|
this.reconnectTimer = void 0;
|
|
@@ -6143,14 +6148,26 @@ var ChatStreamConnection = class {
|
|
|
6143
6148
|
}
|
|
6144
6149
|
this.consecutiveAuthFailures = 0;
|
|
6145
6150
|
this.reconnectDelay = INITIAL_RECONNECT_DELAY_MS;
|
|
6151
|
+
this.staleReconnectRequested = false;
|
|
6152
|
+
this.armStaleTimer();
|
|
6146
6153
|
await this.parseSseStream(response.body, this.abortController.signal);
|
|
6147
6154
|
} catch (error) {
|
|
6155
|
+
this.clearStaleTimer();
|
|
6148
6156
|
if (error.name === "AbortError") {
|
|
6157
|
+
if (this.staleReconnectRequested && this.shouldReconnect && !this.destroyed && this.subscribers.size > 0) {
|
|
6158
|
+
this.staleReconnectRequested = false;
|
|
6159
|
+
this.scheduleReconnect(INITIAL_RECONNECT_DELAY_MS);
|
|
6160
|
+
}
|
|
6149
6161
|
return;
|
|
6150
6162
|
}
|
|
6151
6163
|
if (!this.shouldReconnect || this.destroyed || this.subscribers.size === 0) {
|
|
6152
6164
|
return;
|
|
6153
6165
|
}
|
|
6166
|
+
if (error instanceof chunkKV5SP7RP_cjs.DvinaAuthenticationError) {
|
|
6167
|
+
this.options.onError?.(error);
|
|
6168
|
+
this.close(error);
|
|
6169
|
+
return;
|
|
6170
|
+
}
|
|
6154
6171
|
const isAuthError2 = error instanceof AuthChatStreamError;
|
|
6155
6172
|
if (isAuthError2) {
|
|
6156
6173
|
this.consecutiveAuthFailures += 1;
|
|
@@ -6182,6 +6199,7 @@ var ChatStreamConnection = class {
|
|
|
6182
6199
|
if (done) {
|
|
6183
6200
|
break;
|
|
6184
6201
|
}
|
|
6202
|
+
this.armStaleTimer();
|
|
6185
6203
|
buffer += decoder.decode(value, { stream: true });
|
|
6186
6204
|
const parts = buffer.split(/(?:\r\n|\r|\n){2}/);
|
|
6187
6205
|
buffer = parts.pop() ?? "";
|
|
@@ -6190,6 +6208,7 @@ var ChatStreamConnection = class {
|
|
|
6190
6208
|
}
|
|
6191
6209
|
}
|
|
6192
6210
|
} finally {
|
|
6211
|
+
this.clearStaleTimer();
|
|
6193
6212
|
reader.releaseLock();
|
|
6194
6213
|
}
|
|
6195
6214
|
if (this.shouldReconnect && !this.destroyed && this.subscribers.size > 0) {
|
|
@@ -6214,7 +6233,7 @@ var ChatStreamConnection = class {
|
|
|
6214
6233
|
}
|
|
6215
6234
|
if (eventType === "token-expired") {
|
|
6216
6235
|
this.needsForceRefresh = true;
|
|
6217
|
-
|
|
6236
|
+
throw new AuthChatStreamError(401);
|
|
6218
6237
|
}
|
|
6219
6238
|
if (!eventId || dataLines.length === 0) {
|
|
6220
6239
|
return;
|
|
@@ -6243,6 +6262,26 @@ var ChatStreamConnection = class {
|
|
|
6243
6262
|
void this.doConnect();
|
|
6244
6263
|
}, delay);
|
|
6245
6264
|
}
|
|
6265
|
+
armStaleTimer() {
|
|
6266
|
+
this.clearStaleTimer();
|
|
6267
|
+
if (!this.abortController || !this.shouldReconnect || this.destroyed) {
|
|
6268
|
+
return;
|
|
6269
|
+
}
|
|
6270
|
+
this.staleTimer = setTimeout(() => {
|
|
6271
|
+
if (!this.abortController || !this.shouldReconnect || this.destroyed) {
|
|
6272
|
+
return;
|
|
6273
|
+
}
|
|
6274
|
+
this.staleReconnectRequested = true;
|
|
6275
|
+
this.abortController.abort();
|
|
6276
|
+
}, STALE_CONNECTION_TIMEOUT_MS);
|
|
6277
|
+
}
|
|
6278
|
+
clearStaleTimer() {
|
|
6279
|
+
if (!this.staleTimer) {
|
|
6280
|
+
return;
|
|
6281
|
+
}
|
|
6282
|
+
clearTimeout(this.staleTimer);
|
|
6283
|
+
this.staleTimer = void 0;
|
|
6284
|
+
}
|
|
6246
6285
|
};
|
|
6247
6286
|
var ActiveChatStreamConnection = class {
|
|
6248
6287
|
constructor(options, onEmpty) {
|
|
@@ -6255,6 +6294,8 @@ var ActiveChatStreamConnection = class {
|
|
|
6255
6294
|
needsForceRefresh = false;
|
|
6256
6295
|
reconnectDelay = INITIAL_RECONNECT_DELAY_MS;
|
|
6257
6296
|
reconnectTimer;
|
|
6297
|
+
staleReconnectRequested = false;
|
|
6298
|
+
staleTimer;
|
|
6258
6299
|
shouldReconnect = false;
|
|
6259
6300
|
subscribers = /* @__PURE__ */ new Set();
|
|
6260
6301
|
addSubscriber(subscriber) {
|
|
@@ -6290,6 +6331,8 @@ var ActiveChatStreamConnection = class {
|
|
|
6290
6331
|
close(error) {
|
|
6291
6332
|
this.shouldReconnect = false;
|
|
6292
6333
|
this.destroyed = true;
|
|
6334
|
+
this.staleReconnectRequested = false;
|
|
6335
|
+
this.clearStaleTimer();
|
|
6293
6336
|
if (this.reconnectTimer) {
|
|
6294
6337
|
clearTimeout(this.reconnectTimer);
|
|
6295
6338
|
this.reconnectTimer = void 0;
|
|
@@ -6336,14 +6379,26 @@ var ActiveChatStreamConnection = class {
|
|
|
6336
6379
|
}
|
|
6337
6380
|
this.consecutiveAuthFailures = 0;
|
|
6338
6381
|
this.reconnectDelay = INITIAL_RECONNECT_DELAY_MS;
|
|
6382
|
+
this.staleReconnectRequested = false;
|
|
6383
|
+
this.armStaleTimer();
|
|
6339
6384
|
await this.parseSseStream(response.body, this.abortController.signal);
|
|
6340
6385
|
} catch (error) {
|
|
6386
|
+
this.clearStaleTimer();
|
|
6341
6387
|
if (error.name === "AbortError") {
|
|
6388
|
+
if (this.staleReconnectRequested && this.shouldReconnect && !this.destroyed && this.subscribers.size > 0) {
|
|
6389
|
+
this.staleReconnectRequested = false;
|
|
6390
|
+
this.scheduleReconnect(INITIAL_RECONNECT_DELAY_MS);
|
|
6391
|
+
}
|
|
6342
6392
|
return;
|
|
6343
6393
|
}
|
|
6344
6394
|
if (!this.shouldReconnect || this.destroyed || this.subscribers.size === 0) {
|
|
6345
6395
|
return;
|
|
6346
6396
|
}
|
|
6397
|
+
if (error instanceof chunkKV5SP7RP_cjs.DvinaAuthenticationError) {
|
|
6398
|
+
this.options.onError?.(error);
|
|
6399
|
+
this.close(error);
|
|
6400
|
+
return;
|
|
6401
|
+
}
|
|
6347
6402
|
const isAuthError2 = error instanceof AuthChatStreamError;
|
|
6348
6403
|
if (isAuthError2) {
|
|
6349
6404
|
this.consecutiveAuthFailures += 1;
|
|
@@ -6377,6 +6432,7 @@ var ActiveChatStreamConnection = class {
|
|
|
6377
6432
|
if (done) {
|
|
6378
6433
|
break;
|
|
6379
6434
|
}
|
|
6435
|
+
this.armStaleTimer();
|
|
6380
6436
|
buffer += decoder.decode(value, { stream: true });
|
|
6381
6437
|
const parts = buffer.split(/(?:\r\n|\r|\n){2}/);
|
|
6382
6438
|
buffer = parts.pop() ?? "";
|
|
@@ -6385,6 +6441,7 @@ var ActiveChatStreamConnection = class {
|
|
|
6385
6441
|
}
|
|
6386
6442
|
}
|
|
6387
6443
|
} finally {
|
|
6444
|
+
this.clearStaleTimer();
|
|
6388
6445
|
reader.releaseLock();
|
|
6389
6446
|
}
|
|
6390
6447
|
if (this.shouldReconnect && !this.destroyed && this.subscribers.size > 0) {
|
|
@@ -6406,7 +6463,7 @@ var ActiveChatStreamConnection = class {
|
|
|
6406
6463
|
}
|
|
6407
6464
|
if (eventType === "token-expired") {
|
|
6408
6465
|
this.needsForceRefresh = true;
|
|
6409
|
-
|
|
6466
|
+
throw new AuthChatStreamError(401);
|
|
6410
6467
|
}
|
|
6411
6468
|
if (eventType !== "active" || dataLines.length === 0) {
|
|
6412
6469
|
return;
|
|
@@ -6437,6 +6494,26 @@ var ActiveChatStreamConnection = class {
|
|
|
6437
6494
|
void this.doConnect();
|
|
6438
6495
|
}, delay);
|
|
6439
6496
|
}
|
|
6497
|
+
armStaleTimer() {
|
|
6498
|
+
this.clearStaleTimer();
|
|
6499
|
+
if (!this.abortController || !this.shouldReconnect || this.destroyed) {
|
|
6500
|
+
return;
|
|
6501
|
+
}
|
|
6502
|
+
this.staleTimer = setTimeout(() => {
|
|
6503
|
+
if (!this.abortController || !this.shouldReconnect || this.destroyed) {
|
|
6504
|
+
return;
|
|
6505
|
+
}
|
|
6506
|
+
this.staleReconnectRequested = true;
|
|
6507
|
+
this.abortController.abort();
|
|
6508
|
+
}, STALE_CONNECTION_TIMEOUT_MS);
|
|
6509
|
+
}
|
|
6510
|
+
clearStaleTimer() {
|
|
6511
|
+
if (!this.staleTimer) {
|
|
6512
|
+
return;
|
|
6513
|
+
}
|
|
6514
|
+
clearTimeout(this.staleTimer);
|
|
6515
|
+
this.staleTimer = void 0;
|
|
6516
|
+
}
|
|
6440
6517
|
};
|
|
6441
6518
|
function createChatStreamClient(options) {
|
|
6442
6519
|
const connections = /* @__PURE__ */ new Map();
|
|
@@ -7374,7 +7451,7 @@ function createWsTransport(options) {
|
|
|
7374
7451
|
let nextToken;
|
|
7375
7452
|
let currentToken;
|
|
7376
7453
|
async function refreshToken() {
|
|
7377
|
-
const token = await
|
|
7454
|
+
const token = await chunk4Y42KQCH_cjs.refreshTokenSingleFlight(options.getToken, currentToken);
|
|
7378
7455
|
if (!token) {
|
|
7379
7456
|
throw new chunkKV5SP7RP_cjs.DvinaAuthenticationError("Token refresh did not produce a new token", currentToken);
|
|
7380
7457
|
}
|
|
@@ -7426,7 +7503,7 @@ function createWsTransport(options) {
|
|
|
7426
7503
|
}
|
|
7427
7504
|
});
|
|
7428
7505
|
function subscribe(document2, variables) {
|
|
7429
|
-
const query =
|
|
7506
|
+
const query = chunk4Y42KQCH_cjs.print(document2);
|
|
7430
7507
|
const subscribeOnce = () => ({
|
|
7431
7508
|
[Symbol.asyncIterator]() {
|
|
7432
7509
|
const queue = [];
|
|
@@ -8116,6 +8193,7 @@ var INITIAL_RECONNECT_DELAY_MS2 = 1e3;
|
|
|
8116
8193
|
var MAX_RECONNECT_DELAY_MS2 = 3e4;
|
|
8117
8194
|
var RECONNECT_BACKOFF_MULTIPLIER2 = 2;
|
|
8118
8195
|
var MAX_CONSECUTIVE_AUTH_FAILURES2 = 3;
|
|
8196
|
+
var STALE_CONNECTION_TIMEOUT_MS2 = 35e3;
|
|
8119
8197
|
var SUBSCRIPTION_REFRESH_INTERVAL_MS = 5 * 60 * 1e3;
|
|
8120
8198
|
function createSseTransport(options) {
|
|
8121
8199
|
let abortController;
|
|
@@ -8128,7 +8206,33 @@ function createSseTransport(options) {
|
|
|
8128
8206
|
let needsForceRefresh = false;
|
|
8129
8207
|
let consecutiveAuthFailures = 0;
|
|
8130
8208
|
let hasConnectedOnce = false;
|
|
8209
|
+
let staleReconnectRequested = false;
|
|
8210
|
+
let staleTimer;
|
|
8131
8211
|
const activeSubscriptions = /* @__PURE__ */ new Map();
|
|
8212
|
+
function clearStaleTimer() {
|
|
8213
|
+
if (!staleTimer) {
|
|
8214
|
+
return;
|
|
8215
|
+
}
|
|
8216
|
+
clearTimeout(staleTimer);
|
|
8217
|
+
staleTimer = void 0;
|
|
8218
|
+
}
|
|
8219
|
+
function armStaleTimer() {
|
|
8220
|
+
clearStaleTimer();
|
|
8221
|
+
if (!abortController || !shouldReconnect) {
|
|
8222
|
+
return;
|
|
8223
|
+
}
|
|
8224
|
+
staleTimer = setTimeout(() => {
|
|
8225
|
+
if (!abortController || !shouldReconnect) {
|
|
8226
|
+
return;
|
|
8227
|
+
}
|
|
8228
|
+
staleReconnectRequested = true;
|
|
8229
|
+
abortController.abort();
|
|
8230
|
+
}, STALE_CONNECTION_TIMEOUT_MS2);
|
|
8231
|
+
}
|
|
8232
|
+
function handleTerminalAuthFailure(error) {
|
|
8233
|
+
options.onError?.(error);
|
|
8234
|
+
disconnect();
|
|
8235
|
+
}
|
|
8132
8236
|
async function connect(lastSyncId) {
|
|
8133
8237
|
disconnect();
|
|
8134
8238
|
shouldReconnect = true;
|
|
@@ -8177,17 +8281,29 @@ function createSseTransport(options) {
|
|
|
8177
8281
|
isConnected = true;
|
|
8178
8282
|
consecutiveAuthFailures = 0;
|
|
8179
8283
|
reconnectDelay = INITIAL_RECONNECT_DELAY_MS2;
|
|
8284
|
+
staleReconnectRequested = false;
|
|
8180
8285
|
options.onStateChange?.("connected");
|
|
8181
8286
|
const isReconnect = hasConnectedOnce;
|
|
8182
8287
|
hasConnectedOnce = true;
|
|
8183
8288
|
await syncActiveSubscriptions(token);
|
|
8184
8289
|
startSubscriptionRefresh();
|
|
8290
|
+
armStaleTimer();
|
|
8185
8291
|
if (isReconnect && activeSubscriptions.size > 0) {
|
|
8186
8292
|
options.onReconnect?.();
|
|
8187
8293
|
}
|
|
8188
8294
|
await parseSseStream(response.body, abortController.signal);
|
|
8189
8295
|
} catch (error) {
|
|
8296
|
+
clearStaleTimer();
|
|
8190
8297
|
if (error.name === "AbortError") {
|
|
8298
|
+
if (staleReconnectRequested && shouldReconnect) {
|
|
8299
|
+
staleReconnectRequested = false;
|
|
8300
|
+
isConnected = false;
|
|
8301
|
+
stopSubscriptionRefresh();
|
|
8302
|
+
options.onStateChange?.("disconnected");
|
|
8303
|
+
reconnectTimer = setTimeout(() => {
|
|
8304
|
+
void doConnect();
|
|
8305
|
+
}, INITIAL_RECONNECT_DELAY_MS2);
|
|
8306
|
+
}
|
|
8191
8307
|
return;
|
|
8192
8308
|
}
|
|
8193
8309
|
isConnected = false;
|
|
@@ -8196,10 +8312,16 @@ function createSseTransport(options) {
|
|
|
8196
8312
|
if (!shouldReconnect) {
|
|
8197
8313
|
return;
|
|
8198
8314
|
}
|
|
8315
|
+
if (error instanceof chunkKV5SP7RP_cjs.DvinaAuthenticationError) {
|
|
8316
|
+
handleTerminalAuthFailure(error);
|
|
8317
|
+
return;
|
|
8318
|
+
}
|
|
8199
8319
|
const isAuthError2 = error instanceof AuthSseError;
|
|
8200
8320
|
if (isAuthError2) {
|
|
8201
8321
|
consecutiveAuthFailures += 1;
|
|
8202
8322
|
if (consecutiveAuthFailures >= MAX_CONSECUTIVE_AUTH_FAILURES2) {
|
|
8323
|
+
const authError = new chunkKV5SP7RP_cjs.DvinaAuthenticationError("Sync SSE stream authentication failed permanently");
|
|
8324
|
+
options.onError?.(authError);
|
|
8203
8325
|
disconnect();
|
|
8204
8326
|
return;
|
|
8205
8327
|
}
|
|
@@ -8224,6 +8346,7 @@ function createSseTransport(options) {
|
|
|
8224
8346
|
if (done) {
|
|
8225
8347
|
break;
|
|
8226
8348
|
}
|
|
8349
|
+
armStaleTimer();
|
|
8227
8350
|
buffer += decoder.decode(value, { stream: true });
|
|
8228
8351
|
const parts = buffer.split(/(?:\r\n|\r|\n){2}/);
|
|
8229
8352
|
buffer = parts.pop() ?? "";
|
|
@@ -8232,6 +8355,7 @@ function createSseTransport(options) {
|
|
|
8232
8355
|
}
|
|
8233
8356
|
}
|
|
8234
8357
|
} finally {
|
|
8358
|
+
clearStaleTimer();
|
|
8235
8359
|
reader.releaseLock();
|
|
8236
8360
|
}
|
|
8237
8361
|
if (!shouldReconnect) {
|
|
@@ -8262,7 +8386,7 @@ function createSseTransport(options) {
|
|
|
8262
8386
|
}
|
|
8263
8387
|
if (eventType === "token-expired") {
|
|
8264
8388
|
needsForceRefresh = true;
|
|
8265
|
-
|
|
8389
|
+
throw new AuthSseError(401);
|
|
8266
8390
|
}
|
|
8267
8391
|
if (eventType === "full-resync") {
|
|
8268
8392
|
options.onFullResync?.();
|
|
@@ -8301,6 +8425,8 @@ function createSseTransport(options) {
|
|
|
8301
8425
|
function disconnect() {
|
|
8302
8426
|
shouldReconnect = false;
|
|
8303
8427
|
isConnected = false;
|
|
8428
|
+
staleReconnectRequested = false;
|
|
8429
|
+
clearStaleTimer();
|
|
8304
8430
|
stopSubscriptionRefresh();
|
|
8305
8431
|
if (reconnectTimer) {
|
|
8306
8432
|
clearTimeout(reconnectTimer);
|
|
@@ -8345,7 +8471,12 @@ function createSseTransport(options) {
|
|
|
8345
8471
|
if (activeSubscriptions.size === 0) {
|
|
8346
8472
|
return;
|
|
8347
8473
|
}
|
|
8348
|
-
const resolvedToken = token ?? await options.getToken().catch(() =>
|
|
8474
|
+
const resolvedToken = token ?? await options.getToken().catch((error) => {
|
|
8475
|
+
if (error instanceof chunkKV5SP7RP_cjs.DvinaAuthenticationError) {
|
|
8476
|
+
handleTerminalAuthFailure(error);
|
|
8477
|
+
}
|
|
8478
|
+
return void 0;
|
|
8479
|
+
});
|
|
8349
8480
|
if (!resolvedToken) {
|
|
8350
8481
|
return;
|
|
8351
8482
|
}
|
|
@@ -8357,7 +8488,16 @@ function createSseTransport(options) {
|
|
|
8357
8488
|
);
|
|
8358
8489
|
}
|
|
8359
8490
|
async function postMessage(body, token) {
|
|
8360
|
-
let resolvedToken
|
|
8491
|
+
let resolvedToken;
|
|
8492
|
+
try {
|
|
8493
|
+
resolvedToken = token ?? await options.getToken();
|
|
8494
|
+
} catch (error) {
|
|
8495
|
+
if (error instanceof chunkKV5SP7RP_cjs.DvinaAuthenticationError) {
|
|
8496
|
+
handleTerminalAuthFailure(error);
|
|
8497
|
+
return;
|
|
8498
|
+
}
|
|
8499
|
+
throw error;
|
|
8500
|
+
}
|
|
8361
8501
|
const url = new URL(options.url);
|
|
8362
8502
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
8363
8503
|
const response = await fetch(url.toString(), {
|
|
@@ -8371,7 +8511,15 @@ function createSseTransport(options) {
|
|
|
8371
8511
|
if (response.status !== 401 && response.status !== 403) {
|
|
8372
8512
|
return;
|
|
8373
8513
|
}
|
|
8374
|
-
|
|
8514
|
+
try {
|
|
8515
|
+
resolvedToken = await chunk4Y42KQCH_cjs.refreshTokenSingleFlight(options.getToken, resolvedToken);
|
|
8516
|
+
} catch (error) {
|
|
8517
|
+
if (error instanceof chunkKV5SP7RP_cjs.DvinaAuthenticationError) {
|
|
8518
|
+
handleTerminalAuthFailure(error);
|
|
8519
|
+
return;
|
|
8520
|
+
}
|
|
8521
|
+
throw error;
|
|
8522
|
+
}
|
|
8375
8523
|
}
|
|
8376
8524
|
}
|
|
8377
8525
|
return {
|
|
@@ -10340,7 +10488,7 @@ async function applyRemoteCacheEpoch(db, engine, syncPolicyUrl, getToken) {
|
|
|
10340
10488
|
await db.setLastSyncId("0");
|
|
10341
10489
|
await db.setCacheEpoch(remoteCacheEpoch);
|
|
10342
10490
|
}
|
|
10343
|
-
function createLazySyncEngine(httpTransport, sseUrl, syncPolicyUrl, getToken, getDb) {
|
|
10491
|
+
function createLazySyncEngine(httpTransport, sseUrl, syncPolicyUrl, getToken, getDb, onError) {
|
|
10344
10492
|
let realEngine;
|
|
10345
10493
|
let initPromise;
|
|
10346
10494
|
let activeSseTransport;
|
|
@@ -10355,6 +10503,7 @@ function createLazySyncEngine(httpTransport, sseUrl, syncPolicyUrl, getToken, ge
|
|
|
10355
10503
|
const transport = createSseTransport({
|
|
10356
10504
|
url: sseUrl,
|
|
10357
10505
|
getToken,
|
|
10506
|
+
onError,
|
|
10358
10507
|
onEvent: (event) => {
|
|
10359
10508
|
realEngine?.processSyncEvent(event).catch(() => {
|
|
10360
10509
|
});
|
|
@@ -10627,7 +10776,7 @@ var DB_INIT_TOKEN_POLL_INTERVAL_MS = 100;
|
|
|
10627
10776
|
var DB_INIT_TOKEN_TIMEOUT_MS = 15e3;
|
|
10628
10777
|
var LIFECYCLE_HINT_DEBOUNCE_MS = 250;
|
|
10629
10778
|
function shouldRecoverConnections(hints) {
|
|
10630
|
-
return hints.has("network-restored") || hints.has("app-resumed");
|
|
10779
|
+
return hints.has("network-restored") || hints.has("app-resumed") || hints.has("became-active");
|
|
10631
10780
|
}
|
|
10632
10781
|
function resolveGetToken(options) {
|
|
10633
10782
|
if ("getToken" in options && options.getToken) {
|
|
@@ -10657,6 +10806,9 @@ async function waitForDatabaseToken(getToken) {
|
|
|
10657
10806
|
return token;
|
|
10658
10807
|
}
|
|
10659
10808
|
} catch (error) {
|
|
10809
|
+
if (error instanceof chunkKV5SP7RP_cjs.DvinaAuthenticationError) {
|
|
10810
|
+
throw error;
|
|
10811
|
+
}
|
|
10660
10812
|
lastError = error;
|
|
10661
10813
|
}
|
|
10662
10814
|
if (Date.now() >= deadlineAt) {
|
|
@@ -10678,7 +10830,7 @@ function createDvinaClient(options) {
|
|
|
10678
10830
|
const getToken = resolveGetToken(options);
|
|
10679
10831
|
const getLanguage = resolveLanguage(options.language);
|
|
10680
10832
|
const getUserTimezone = resolveUserTimezone();
|
|
10681
|
-
const httpTransport =
|
|
10833
|
+
const httpTransport = chunk4Y42KQCH_cjs.createHttpTransport({
|
|
10682
10834
|
url: httpUrl,
|
|
10683
10835
|
getToken,
|
|
10684
10836
|
getLanguage,
|
|
@@ -10725,7 +10877,7 @@ function createDvinaClient(options) {
|
|
|
10725
10877
|
dbInitPromise = void 0;
|
|
10726
10878
|
});
|
|
10727
10879
|
}
|
|
10728
|
-
const syncEngine = createLazySyncEngine(httpTransport, sseUrl, syncPolicyUrl, getToken, getDb);
|
|
10880
|
+
const syncEngine = createLazySyncEngine(httpTransport, sseUrl, syncPolicyUrl, getToken, getDb, options.onError);
|
|
10729
10881
|
const recoverableSyncEngine = syncEngine;
|
|
10730
10882
|
const request = async (document2, variables, _options) => {
|
|
10731
10883
|
return syncEngine.query(document2, variables);
|
|
@@ -10737,7 +10889,7 @@ function createDvinaClient(options) {
|
|
|
10737
10889
|
const billingBase = hasProtocol ? billingOverride.replace(/\/+$/, "") : `${httpProtocol}://${billingOverride ?? baseUrl.replace(/^api\./, "billing.")}`;
|
|
10738
10890
|
const billingHttpUrl = `${billingBase}/graphql`;
|
|
10739
10891
|
const billingSseUrl = `${billingBase}/subscriptions/stream`;
|
|
10740
|
-
const billing = new
|
|
10892
|
+
const billing = new chunk4Y42KQCH_cjs.BillingClient({ billingHttpUrl, billingSseUrl, getToken, onError: options.onError });
|
|
10741
10893
|
let lifecycleHintTimer;
|
|
10742
10894
|
const pendingLifecycleHints = /* @__PURE__ */ new Set();
|
|
10743
10895
|
const recoverConnections = () => {
|
|
@@ -11080,7 +11232,7 @@ function buildSmartQuery(baseDocument, rootFieldName, includes, baseVariables, i
|
|
|
11080
11232
|
}
|
|
11081
11233
|
const doc = cloneDocument(baseDocument);
|
|
11082
11234
|
const mergedVariables = { ...baseVariables };
|
|
11083
|
-
const opDef = doc.definitions.find((d) => d.kind ===
|
|
11235
|
+
const opDef = doc.definitions.find((d) => d.kind === chunk4Y42KQCH_cjs.Kind.OPERATION_DEFINITION);
|
|
11084
11236
|
if (!opDef) {
|
|
11085
11237
|
return { document: baseDocument, variables: baseVariables };
|
|
11086
11238
|
}
|
|
@@ -11090,7 +11242,7 @@ function buildSmartQuery(baseDocument, rootFieldName, includes, baseVariables, i
|
|
|
11090
11242
|
}
|
|
11091
11243
|
const existingFragments = /* @__PURE__ */ new Set();
|
|
11092
11244
|
for (const def of doc.definitions) {
|
|
11093
|
-
if (def.kind ===
|
|
11245
|
+
if (def.kind === chunk4Y42KQCH_cjs.Kind.FRAGMENT_DEFINITION) {
|
|
11094
11246
|
existingFragments.add(def.name.value);
|
|
11095
11247
|
}
|
|
11096
11248
|
}
|
|
@@ -11114,10 +11266,10 @@ function buildSmartQuery(baseDocument, rootFieldName, includes, baseVariables, i
|
|
|
11114
11266
|
}
|
|
11115
11267
|
if (isConnection && connectionIncludeFields.length > 0) {
|
|
11116
11268
|
const nodesWrapper = {
|
|
11117
|
-
kind:
|
|
11118
|
-
name: { kind:
|
|
11269
|
+
kind: chunk4Y42KQCH_cjs.Kind.FIELD,
|
|
11270
|
+
name: { kind: chunk4Y42KQCH_cjs.Kind.NAME, value: "nodes" },
|
|
11119
11271
|
selectionSet: {
|
|
11120
|
-
kind:
|
|
11272
|
+
kind: chunk4Y42KQCH_cjs.Kind.SELECTION_SET,
|
|
11121
11273
|
selections: connectionIncludeFields
|
|
11122
11274
|
}
|
|
11123
11275
|
};
|
|
@@ -11131,14 +11283,14 @@ function buildSmartQuery(baseDocument, rootFieldName, includes, baseVariables, i
|
|
|
11131
11283
|
function processIncludeDirective(include, prefix, opDef, mergedVariables, existingFragments, newDefinitions) {
|
|
11132
11284
|
const fieldArgs = buildPrefixedArguments(include.fieldArguments ?? [], prefix);
|
|
11133
11285
|
const fragmentDefs = include.fragmentDoc.definitions.filter(
|
|
11134
|
-
(d) => d.kind ===
|
|
11286
|
+
(d) => d.kind === chunk4Y42KQCH_cjs.Kind.FRAGMENT_DEFINITION
|
|
11135
11287
|
);
|
|
11136
11288
|
const mainFragment = fragmentDefs[0];
|
|
11137
11289
|
if (!mainFragment) return void 0;
|
|
11138
11290
|
const selections = [
|
|
11139
11291
|
{
|
|
11140
|
-
kind:
|
|
11141
|
-
name: { kind:
|
|
11292
|
+
kind: chunk4Y42KQCH_cjs.Kind.FRAGMENT_SPREAD,
|
|
11293
|
+
name: { kind: chunk4Y42KQCH_cjs.Kind.NAME, value: mainFragment.name.value }
|
|
11142
11294
|
}
|
|
11143
11295
|
];
|
|
11144
11296
|
if (include.children && include.children.length > 0) {
|
|
@@ -11160,10 +11312,10 @@ function processIncludeDirective(include, prefix, opDef, mergedVariables, existi
|
|
|
11160
11312
|
if (childFields.length > 0) {
|
|
11161
11313
|
if (include.isConnection) {
|
|
11162
11314
|
const nodesWrapper = {
|
|
11163
|
-
kind:
|
|
11164
|
-
name: { kind:
|
|
11315
|
+
kind: chunk4Y42KQCH_cjs.Kind.FIELD,
|
|
11316
|
+
name: { kind: chunk4Y42KQCH_cjs.Kind.NAME, value: "nodes" },
|
|
11165
11317
|
selectionSet: {
|
|
11166
|
-
kind:
|
|
11318
|
+
kind: chunk4Y42KQCH_cjs.Kind.SELECTION_SET,
|
|
11167
11319
|
selections: childFields
|
|
11168
11320
|
}
|
|
11169
11321
|
};
|
|
@@ -11174,11 +11326,11 @@ function processIncludeDirective(include, prefix, opDef, mergedVariables, existi
|
|
|
11174
11326
|
}
|
|
11175
11327
|
}
|
|
11176
11328
|
const includeField = {
|
|
11177
|
-
kind:
|
|
11178
|
-
name: { kind:
|
|
11329
|
+
kind: chunk4Y42KQCH_cjs.Kind.FIELD,
|
|
11330
|
+
name: { kind: chunk4Y42KQCH_cjs.Kind.NAME, value: include.fieldName },
|
|
11179
11331
|
arguments: fieldArgs.length > 0 ? fieldArgs : void 0,
|
|
11180
11332
|
selectionSet: {
|
|
11181
|
-
kind:
|
|
11333
|
+
kind: chunk4Y42KQCH_cjs.Kind.SELECTION_SET,
|
|
11182
11334
|
selections
|
|
11183
11335
|
}
|
|
11184
11336
|
};
|
|
@@ -11205,7 +11357,7 @@ function processIncludeDirective(include, prefix, opDef, mergedVariables, existi
|
|
|
11205
11357
|
}
|
|
11206
11358
|
function findFieldInSelectionSet(selectionSet, fieldName) {
|
|
11207
11359
|
for (const selection of selectionSet.selections) {
|
|
11208
|
-
if (selection.kind ===
|
|
11360
|
+
if (selection.kind === chunk4Y42KQCH_cjs.Kind.FIELD && selection.name.value === fieldName) {
|
|
11209
11361
|
return selection;
|
|
11210
11362
|
}
|
|
11211
11363
|
}
|
|
@@ -11219,7 +11371,7 @@ function buildPrefixedArguments(args, prefix) {
|
|
|
11219
11371
|
});
|
|
11220
11372
|
}
|
|
11221
11373
|
function prefixVariableReferences(node, prefix) {
|
|
11222
|
-
if (node["kind"] ===
|
|
11374
|
+
if (node["kind"] === chunk4Y42KQCH_cjs.Kind.VARIABLE && typeof node["name"]?.["value"] === "string") {
|
|
11223
11375
|
node["name"]["value"] = `${prefix}${node["name"]["value"]}`;
|
|
11224
11376
|
return;
|
|
11225
11377
|
}
|
|
@@ -11244,7 +11396,7 @@ function buildPrefixedVariableDefinitions(varDefs, prefix) {
|
|
|
11244
11396
|
}
|
|
11245
11397
|
function extractIncludeInfo(nestedDocument, nestedFieldName, parentVarNames) {
|
|
11246
11398
|
const opDef = nestedDocument.definitions.find(
|
|
11247
|
-
(d) => d.kind ===
|
|
11399
|
+
(d) => d.kind === chunk4Y42KQCH_cjs.Kind.OPERATION_DEFINITION
|
|
11248
11400
|
);
|
|
11249
11401
|
if (!opDef) {
|
|
11250
11402
|
return { variableDefinitions: [], fieldArguments: [] };
|
|
@@ -11256,7 +11408,7 @@ function extractIncludeInfo(nestedDocument, nestedFieldName, parentVarNames) {
|
|
|
11256
11408
|
let fieldArguments = [];
|
|
11257
11409
|
function findNestedField(selectionSet) {
|
|
11258
11410
|
for (const sel of selectionSet.selections) {
|
|
11259
|
-
if (sel.kind ===
|
|
11411
|
+
if (sel.kind === chunk4Y42KQCH_cjs.Kind.FIELD) {
|
|
11260
11412
|
if (sel.name.value === nestedFieldName && sel.arguments) {
|
|
11261
11413
|
fieldArguments = sel.arguments;
|
|
11262
11414
|
return;
|
|
@@ -23363,5 +23515,5 @@ exports.getOrCreateDatabase = getOrCreateDatabase;
|
|
|
23363
23515
|
exports.reconstructConnectionNodes = reconstructConnectionNodes;
|
|
23364
23516
|
exports.reconstructEntity = reconstructEntity;
|
|
23365
23517
|
exports.uploadFile = uploadFile;
|
|
23366
|
-
//# sourceMappingURL=chunk-
|
|
23367
|
-
//# sourceMappingURL=chunk-
|
|
23518
|
+
//# sourceMappingURL=chunk-AU5C7Y4P.cjs.map
|
|
23519
|
+
//# sourceMappingURL=chunk-AU5C7Y4P.cjs.map
|