@dvina/sdk 4.0.221 → 4.0.232

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.
Files changed (31) hide show
  1. package/dist/adapters/angular/index.cjs +4 -4
  2. package/dist/adapters/angular/index.d.cts +2 -2
  3. package/dist/adapters/angular/index.d.ts +2 -2
  4. package/dist/adapters/angular/index.js +2 -2
  5. package/dist/billing/index.cjs +5 -5
  6. package/dist/billing/index.js +1 -1
  7. package/dist/{chunk-VDPZQ5F3.cjs → chunk-4Y42KQCH.cjs} +22 -68
  8. package/dist/chunk-4Y42KQCH.cjs.map +1 -0
  9. package/dist/{chunk-ZGGY4WK7.js → chunk-RVXRT5EI.js} +22 -68
  10. package/dist/chunk-RVXRT5EI.js.map +1 -0
  11. package/dist/{chunk-LNQAR2M2.cjs → chunk-SXCZIX2Z.cjs} +187 -35
  12. package/dist/chunk-SXCZIX2Z.cjs.map +1 -0
  13. package/dist/{chunk-I7HS5CQ7.js → chunk-YXGWZRDY.js} +165 -13
  14. package/dist/chunk-YXGWZRDY.js.map +1 -0
  15. package/dist/{client-BAich_Hx.d.cts → client-DI2pYavC.d.cts} +1 -1
  16. package/dist/{client-DW2pRGde.d.ts → client-DRZeTTgS.d.ts} +1 -1
  17. package/dist/{index-DF59UYzN.d.cts → index-Bwe8KY0Z.d.cts} +1 -1
  18. package/dist/{index-Bld5-Yr1.d.ts → index-DqQrAjp3.d.ts} +1 -1
  19. package/dist/index.cjs +390 -390
  20. package/dist/index.d.cts +10 -10
  21. package/dist/index.d.ts +10 -10
  22. package/dist/index.js +2 -2
  23. package/dist/pagination/index.d.cts +2 -2
  24. package/dist/pagination/index.d.ts +2 -2
  25. package/dist/{sync-engine-CZ0U9XBy.d.ts → sync-engine-CYIG5amb.d.ts} +5 -2
  26. package/dist/{sync-engine-DXESBFX0.d.cts → sync-engine-DPVgCDPC.d.cts} +5 -2
  27. package/package.json +1 -1
  28. package/dist/chunk-I7HS5CQ7.js.map +0 -1
  29. package/dist/chunk-LNQAR2M2.cjs.map +0 -1
  30. package/dist/chunk-VDPZQ5F3.cjs.map +0 -1
  31. package/dist/chunk-ZGGY4WK7.js.map +0 -1
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkLNQAR2M2_cjs = require('../../chunk-LNQAR2M2.cjs');
3
+ var chunkSXCZIX2Z_cjs = require('../../chunk-SXCZIX2Z.cjs');
4
4
  require('../../chunk-342BFYZZ.cjs');
5
5
  require('../../chunk-UELAE75E.cjs');
6
- require('../../chunk-VDPZQ5F3.cjs');
6
+ require('../../chunk-4Y42KQCH.cjs');
7
7
  require('../../chunk-KV5SP7RP.cjs');
8
8
  require('../../chunk-5G4TDB2H.cjs');
9
9
  require('../../chunk-DZUJEN5N.cjs');
@@ -147,10 +147,10 @@ function hasDispose(value) {
147
147
  function provideDvina(optionsOrFactory) {
148
148
  return core.makeEnvironmentProviders([
149
149
  {
150
- provide: chunkLNQAR2M2_cjs.DvinaSdk,
150
+ provide: chunkSXCZIX2Z_cjs.DvinaSdk,
151
151
  useFactory: () => {
152
152
  const options = typeof optionsOrFactory === "function" ? optionsOrFactory() : optionsOrFactory;
153
- return new chunkLNQAR2M2_cjs.DvinaSdk(options);
153
+ return new chunkSXCZIX2Z_cjs.DvinaSdk(options);
154
154
  }
155
155
  }
156
156
  ]);
@@ -1,8 +1,8 @@
1
1
  import { Signal, DestroyRef, EnvironmentProviders } from '@angular/core';
2
- import { D as DvinaSdkOptions } from '../../client-BAich_Hx.cjs';
2
+ import { D as DvinaSdkOptions } from '../../client-DI2pYavC.cjs';
3
3
  import { D as DvinaQueryRef } from '../../types-2RotD0Ab.cjs';
4
4
  import '../../error-CsVoUTY8.cjs';
5
- import '../../sync-engine-DXESBFX0.cjs';
5
+ import '../../sync-engine-DPVgCDPC.cjs';
6
6
  import 'graphql';
7
7
  import 'dexie';
8
8
  import '../../client-Bb2gD6Iz.cjs';
@@ -1,8 +1,8 @@
1
1
  import { Signal, DestroyRef, EnvironmentProviders } from '@angular/core';
2
- import { D as DvinaSdkOptions } from '../../client-DW2pRGde.js';
2
+ import { D as DvinaSdkOptions } from '../../client-DRZeTTgS.js';
3
3
  import { D as DvinaQueryRef } from '../../types-2RotD0Ab.js';
4
4
  import '../../error-CsVoUTY8.js';
5
- import '../../sync-engine-CZ0U9XBy.js';
5
+ import '../../sync-engine-CYIG5amb.js';
6
6
  import 'graphql';
7
7
  import 'dexie';
8
8
  import '../../client-Bb2gD6Iz.js';
@@ -1,7 +1,7 @@
1
- import { DvinaSdk } from '../../chunk-I7HS5CQ7.js';
1
+ import { DvinaSdk } from '../../chunk-YXGWZRDY.js';
2
2
  import '../../chunk-KEM6SUTS.js';
3
3
  import '../../chunk-PDM2KR7T.js';
4
- import '../../chunk-ZGGY4WK7.js';
4
+ import '../../chunk-RVXRT5EI.js';
5
5
  import '../../chunk-7XBJ77RJ.js';
6
6
  import '../../chunk-QELS6XG7.js';
7
7
  import '../../chunk-5WRI5ZAA.js';
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkVDPZQ5F3_cjs = require('../chunk-VDPZQ5F3.cjs');
3
+ var chunk4Y42KQCH_cjs = require('../chunk-4Y42KQCH.cjs');
4
4
  require('../chunk-KV5SP7RP.cjs');
5
5
  require('../chunk-DZUJEN5N.cjs');
6
6
 
@@ -8,19 +8,19 @@ require('../chunk-DZUJEN5N.cjs');
8
8
 
9
9
  Object.defineProperty(exports, "BillingClient", {
10
10
  enumerable: true,
11
- get: function () { return chunkVDPZQ5F3_cjs.BillingClient; }
11
+ get: function () { return chunk4Y42KQCH_cjs.BillingClient; }
12
12
  });
13
13
  Object.defineProperty(exports, "EntitlementTier", {
14
14
  enumerable: true,
15
- get: function () { return chunkVDPZQ5F3_cjs.EntitlementTier; }
15
+ get: function () { return chunk4Y42KQCH_cjs.EntitlementTier; }
16
16
  });
17
17
  Object.defineProperty(exports, "SubscriptionCycle", {
18
18
  enumerable: true,
19
- get: function () { return chunkVDPZQ5F3_cjs.SubscriptionCycle; }
19
+ get: function () { return chunk4Y42KQCH_cjs.SubscriptionCycle; }
20
20
  });
21
21
  Object.defineProperty(exports, "SubscriptionProvider", {
22
22
  enumerable: true,
23
- get: function () { return chunkVDPZQ5F3_cjs.SubscriptionProvider; }
23
+ get: function () { return chunk4Y42KQCH_cjs.SubscriptionProvider; }
24
24
  });
25
25
  //# sourceMappingURL=index.cjs.map
26
26
  //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,4 @@
1
- export { BillingClient, EntitlementTier, SubscriptionCycle, SubscriptionProvider } from '../chunk-ZGGY4WK7.js';
1
+ export { BillingClient, EntitlementTier, SubscriptionCycle, SubscriptionProvider } from '../chunk-RVXRT5EI.js';
2
2
  import '../chunk-7XBJ77RJ.js';
3
3
  import '../chunk-5WRI5ZAA.js';
4
4
  //# sourceMappingURL=index.js.map
@@ -853,44 +853,11 @@ function hasMultilineItems(maybeArray) {
853
853
  }
854
854
 
855
855
  // src/transport/core/token-refresh.ts
856
- var REFRESH_FAILURE_COOLDOWN_MS = 6e4;
857
856
  var inFlightRefreshes = /* @__PURE__ */ new WeakMap();
858
- var recentRefreshFailures = /* @__PURE__ */ new WeakMap();
859
- function getBlockedRefreshError(getToken) {
860
- const recentFailure = recentRefreshFailures.get(getToken);
861
- if (!recentFailure) {
862
- return void 0;
863
- }
864
- if (recentFailure.retryAt <= Date.now()) {
865
- recentRefreshFailures.delete(getToken);
866
- return void 0;
867
- }
868
- return recentFailure.error;
869
- }
870
- function rememberRefreshFailure(getToken, error) {
871
- const normalizedError = error instanceof Error ? error : new chunkKV5SP7RP_cjs.DvinaAuthenticationError("Token refresh failed unexpectedly");
872
- recentRefreshFailures.set(getToken, {
873
- error: normalizedError,
874
- retryAt: Date.now() + REFRESH_FAILURE_COOLDOWN_MS
875
- });
876
- return normalizedError;
877
- }
878
- function clearRefreshFailure(getToken) {
879
- recentRefreshFailures.delete(getToken);
880
- }
881
857
  async function refreshTokenSingleFlight(getToken, failedToken) {
882
- const blockedError = getBlockedRefreshError(getToken);
883
- if (blockedError) {
884
- throw blockedError;
885
- }
886
858
  let inFlight = inFlightRefreshes.get(getToken);
887
859
  if (!inFlight) {
888
- const refreshPromise = getToken({ forceRefresh: true }).then((token) => {
889
- clearRefreshFailure(getToken);
890
- return token;
891
- }).catch((error) => {
892
- throw rememberRefreshFailure(getToken, error);
893
- }).finally(() => {
860
+ const refreshPromise = getToken({ forceRefresh: true }).finally(() => {
894
861
  if (inFlightRefreshes.get(getToken) === refreshPromise) {
895
862
  inFlightRefreshes.delete(getToken);
896
863
  }
@@ -900,12 +867,8 @@ async function refreshTokenSingleFlight(getToken, failedToken) {
900
867
  }
901
868
  const refreshedToken = await inFlight;
902
869
  if (failedToken && refreshedToken === failedToken) {
903
- throw rememberRefreshFailure(
904
- getToken,
905
- new chunkKV5SP7RP_cjs.DvinaAuthenticationError("Token refresh did not produce a new token", failedToken)
906
- );
870
+ throw new chunkKV5SP7RP_cjs.DvinaAuthenticationError("Token refresh did not produce a new token", failedToken);
907
871
  }
908
- clearRefreshFailure(getToken);
909
872
  return refreshedToken;
910
873
  }
911
874
 
@@ -986,17 +949,13 @@ async function doFetch(options, document, variables) {
986
949
  var MAX_RETRIES = 4;
987
950
  var RETRY_DELAY_MS = 1e3;
988
951
  function createHttpTransport(options) {
989
- const refreshState = {
990
- isRefreshing: false,
991
- pendingRequests: []
992
- };
993
952
  async function requestWithRetry(document, variables, attempt = 0) {
994
953
  let fetchResult;
995
954
  try {
996
955
  fetchResult = await doFetch(options, document, variables);
997
956
  } catch (error) {
998
957
  if (error instanceof chunkKV5SP7RP_cjs.DvinaAuthenticationError) {
999
- return handleAuthRefresh(document, variables, refreshState, options, error.failedToken);
958
+ return handleAuthRefresh(document, variables, options, error.failedToken);
1000
959
  }
1001
960
  if (error instanceof chunkKV5SP7RP_cjs.DvinaNetworkError && error.status === 0 && attempt < MAX_RETRIES) {
1002
961
  await sleep(RETRY_DELAY_MS * (attempt + 1));
@@ -1007,7 +966,7 @@ function createHttpTransport(options) {
1007
966
  }
1008
967
  const { response: result, usedToken } = fetchResult;
1009
968
  if (isAuthError(result.errors)) {
1010
- return handleAuthRefresh(document, variables, refreshState, options, usedToken);
969
+ return handleAuthRefresh(document, variables, options, usedToken);
1011
970
  }
1012
971
  if (result.errors?.length && !result.data) {
1013
972
  const error = chunkKV5SP7RP_cjs.createGraphQLError(result.errors, printDocument(document), variables);
@@ -1029,27 +988,14 @@ function createHttpTransport(options) {
1029
988
  request: (document, variables) => requestWithRetry(document, variables)
1030
989
  };
1031
990
  }
1032
- async function handleAuthRefresh(document, variables, refreshState, options, failedToken) {
1033
- if (!refreshState.isRefreshing) {
1034
- refreshState.isRefreshing = true;
1035
- try {
1036
- await refreshTokenSingleFlight(options.getToken, failedToken);
1037
- refreshState.pendingRequests.forEach((req) => req.resolve());
1038
- refreshState.pendingRequests = [];
1039
- refreshState.isRefreshing = false;
1040
- } catch {
1041
- const error = new chunkKV5SP7RP_cjs.DvinaAuthenticationError("Token refresh failed");
1042
- options.onError?.(error);
1043
- refreshState.pendingRequests.forEach((req) => req.reject(error));
1044
- refreshState.pendingRequests = [];
1045
- refreshState.isRefreshing = false;
1046
- throw error;
1047
- }
1048
- return retryAfterRefresh(options, document, variables);
991
+ async function handleAuthRefresh(document, variables, options, failedToken) {
992
+ try {
993
+ await refreshTokenSingleFlight(options.getToken, failedToken);
994
+ } catch {
995
+ const error = new chunkKV5SP7RP_cjs.DvinaAuthenticationError("Token refresh failed");
996
+ options.onError?.(error);
997
+ throw error;
1049
998
  }
1050
- await new Promise((resolve, reject) => {
1051
- refreshState.pendingRequests.push({ resolve, reject });
1052
- });
1053
999
  return retryAfterRefresh(options, document, variables);
1054
1000
  }
1055
1001
  async function retryAfterRefresh(options, document, variables) {
@@ -1223,6 +1169,14 @@ var ConnectionSupervisor = class {
1223
1169
  }
1224
1170
  handleFailure(error) {
1225
1171
  this.lastError = error;
1172
+ if (error instanceof chunkKV5SP7RP_cjs.DvinaAuthenticationError) {
1173
+ this.shouldRun = false;
1174
+ this.clearReconnectTimer();
1175
+ this.clearStaleTimer();
1176
+ this.setState("failed");
1177
+ this.options.onFatalError?.(error);
1178
+ return;
1179
+ }
1226
1180
  const isAuthError2 = this.options.isAuthError?.(error) ?? false;
1227
1181
  if (isAuthError2) {
1228
1182
  this.consecutiveAuthFailures += 1;
@@ -1353,7 +1307,7 @@ async function consumeSseStream(body, signal, handlers) {
1353
1307
  var INITIAL_RECONNECT_DELAY_MS = 1e3;
1354
1308
  var MAX_RECONNECT_DELAY_MS = 3e4;
1355
1309
  var MAX_CONSECUTIVE_AUTH_FAILURES = 3;
1356
- var STALE_CONNECTION_TIMEOUT_MS = 6e4;
1310
+ var STALE_CONNECTION_TIMEOUT_MS = 35e3;
1357
1311
  var BillingAuthStreamError = class extends Error {
1358
1312
  constructor(status) {
1359
1313
  super(`Billing SSE auth failed: ${status}`);
@@ -1646,5 +1600,5 @@ exports.SubscriptionProvider = SubscriptionProvider;
1646
1600
  exports.createHttpTransport = createHttpTransport;
1647
1601
  exports.print = print;
1648
1602
  exports.refreshTokenSingleFlight = refreshTokenSingleFlight;
1649
- //# sourceMappingURL=chunk-VDPZQ5F3.cjs.map
1650
- //# sourceMappingURL=chunk-VDPZQ5F3.cjs.map
1603
+ //# sourceMappingURL=chunk-4Y42KQCH.cjs.map
1604
+ //# sourceMappingURL=chunk-4Y42KQCH.cjs.map