@dvina/sdk 4.0.217 → 4.0.220

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 (30) 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-IM7TFRLL.js → chunk-6PAEAOGQ.js} +94 -30
  8. package/dist/chunk-6PAEAOGQ.js.map +1 -0
  9. package/dist/{chunk-SQ3TK5MI.cjs → chunk-CGJTK2BE.cjs} +117 -53
  10. package/dist/chunk-CGJTK2BE.cjs.map +1 -0
  11. package/dist/{chunk-5JLVHE5X.cjs → chunk-VDPZQ5F3.cjs} +41 -4
  12. package/dist/{chunk-5JLVHE5X.cjs.map → chunk-VDPZQ5F3.cjs.map} +1 -1
  13. package/dist/{chunk-GJXK5EID.js → chunk-ZGGY4WK7.js} +41 -4
  14. package/dist/chunk-ZGGY4WK7.js.map +1 -0
  15. package/dist/{client-B4c82App.d.ts → client-C0CA6PHq.d.ts} +1 -1
  16. package/dist/{client-CluqWlY-.d.cts → client-XvsWJ1Z1.d.cts} +1 -1
  17. package/dist/{index-DCrLPp9U.d.ts → index-Bld5-Yr1.d.ts} +1 -1
  18. package/dist/{index-D2HJtzDx.d.cts → index-DF59UYzN.d.cts} +1 -1
  19. package/dist/index.cjs +387 -387
  20. package/dist/index.d.cts +6 -6
  21. package/dist/index.d.ts +6 -6
  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-CBYlsAfA.d.ts → sync-engine-CZ0U9XBy.d.ts} +13 -7
  26. package/dist/{sync-engine-CvB6DrbK.d.cts → sync-engine-DXESBFX0.d.cts} +13 -7
  27. package/package.json +1 -1
  28. package/dist/chunk-GJXK5EID.js.map +0 -1
  29. package/dist/chunk-IM7TFRLL.js.map +0 -1
  30. package/dist/chunk-SQ3TK5MI.cjs.map +0 -1
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkSQ3TK5MI_cjs = require('../../chunk-SQ3TK5MI.cjs');
3
+ var chunkCGJTK2BE_cjs = require('../../chunk-CGJTK2BE.cjs');
4
4
  require('../../chunk-342BFYZZ.cjs');
5
5
  require('../../chunk-UELAE75E.cjs');
6
- require('../../chunk-5JLVHE5X.cjs');
6
+ require('../../chunk-VDPZQ5F3.cjs');
7
7
  require('../../chunk-KV5SP7RP.cjs');
8
8
  require('../../chunk-32A6N4YK.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: chunkSQ3TK5MI_cjs.DvinaSdk,
150
+ provide: chunkCGJTK2BE_cjs.DvinaSdk,
151
151
  useFactory: () => {
152
152
  const options = typeof optionsOrFactory === "function" ? optionsOrFactory() : optionsOrFactory;
153
- return new chunkSQ3TK5MI_cjs.DvinaSdk(options);
153
+ return new chunkCGJTK2BE_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-CluqWlY-.cjs';
2
+ import { D as DvinaSdkOptions } from '../../client-XvsWJ1Z1.cjs';
3
3
  import { D as DvinaQueryRef } from '../../types-2RotD0Ab.cjs';
4
4
  import '../../error-CsVoUTY8.cjs';
5
- import '../../sync-engine-CvB6DrbK.cjs';
5
+ import '../../sync-engine-DXESBFX0.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-B4c82App.js';
2
+ import { D as DvinaSdkOptions } from '../../client-C0CA6PHq.js';
3
3
  import { D as DvinaQueryRef } from '../../types-2RotD0Ab.js';
4
4
  import '../../error-CsVoUTY8.js';
5
- import '../../sync-engine-CBYlsAfA.js';
5
+ import '../../sync-engine-CZ0U9XBy.js';
6
6
  import 'graphql';
7
7
  import 'dexie';
8
8
  import '../../client-Bb2gD6Iz.js';
@@ -1,7 +1,7 @@
1
- import { DvinaSdk } from '../../chunk-IM7TFRLL.js';
1
+ import { DvinaSdk } from '../../chunk-6PAEAOGQ.js';
2
2
  import '../../chunk-KEM6SUTS.js';
3
3
  import '../../chunk-PDM2KR7T.js';
4
- import '../../chunk-GJXK5EID.js';
4
+ import '../../chunk-ZGGY4WK7.js';
5
5
  import '../../chunk-7XBJ77RJ.js';
6
6
  import '../../chunk-ETPR6MV5.js';
7
7
  import '../../chunk-5WRI5ZAA.js';
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk5JLVHE5X_cjs = require('../chunk-5JLVHE5X.cjs');
3
+ var chunkVDPZQ5F3_cjs = require('../chunk-VDPZQ5F3.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 chunk5JLVHE5X_cjs.BillingClient; }
11
+ get: function () { return chunkVDPZQ5F3_cjs.BillingClient; }
12
12
  });
13
13
  Object.defineProperty(exports, "EntitlementTier", {
14
14
  enumerable: true,
15
- get: function () { return chunk5JLVHE5X_cjs.EntitlementTier; }
15
+ get: function () { return chunkVDPZQ5F3_cjs.EntitlementTier; }
16
16
  });
17
17
  Object.defineProperty(exports, "SubscriptionCycle", {
18
18
  enumerable: true,
19
- get: function () { return chunk5JLVHE5X_cjs.SubscriptionCycle; }
19
+ get: function () { return chunkVDPZQ5F3_cjs.SubscriptionCycle; }
20
20
  });
21
21
  Object.defineProperty(exports, "SubscriptionProvider", {
22
22
  enumerable: true,
23
- get: function () { return chunk5JLVHE5X_cjs.SubscriptionProvider; }
23
+ get: function () { return chunkVDPZQ5F3_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-GJXK5EID.js';
1
+ export { BillingClient, EntitlementTier, SubscriptionCycle, SubscriptionProvider } from '../chunk-ZGGY4WK7.js';
2
2
  import '../chunk-7XBJ77RJ.js';
3
3
  import '../chunk-5WRI5ZAA.js';
4
4
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  import { Request, Connection, PageInfo, defaultConnection } from './chunk-KEM6SUTS.js';
2
2
  import { createInferenceClientInternal } from './chunk-PDM2KR7T.js';
3
- import { createHttpTransport, BillingClient, refreshTokenSingleFlight, print, Kind } from './chunk-GJXK5EID.js';
3
+ import { createHttpTransport, BillingClient, refreshTokenSingleFlight, print, Kind } from './chunk-ZGGY4WK7.js';
4
4
  import { GRAPHQL_ERROR_CODES, DvinaAuthenticationError, DvinaNetworkError, DvinaGraphQLError, DvinaError, createGraphQLError } from './chunk-7XBJ77RJ.js';
5
5
  import { ChatConnectionFragmentDoc, ChatFragmentDoc, FileFragmentDoc, ChatMessageFragmentDoc, AgentConnectionFragmentDoc, ArtifactConnectionFragmentDoc, DesktopDeviceFragmentDoc, InsightFragmentDoc, ChatMessageConnectionFragmentDoc, ProjectFragmentDoc, ContentBlockFragmentDoc, FeedbackFragmentDoc, DatabaseEngineFragmentDoc, TableConnectionFragmentDoc, ProjectDesktopBindingFragmentDoc, DocumentContentFragmentDoc, DocumentFormatFragmentDoc, FeedSendMessageActionFragmentDoc, FeedArtifactDataFragmentDoc, ReportMemberFragmentDoc, ReportConnectionFragmentDoc, IntegrationProviderFragmentDoc, FeedItemGeneratedFragmentDoc, CandidateFragmentDoc, IntegrationFragmentDoc, InsightConnectionFragmentDoc, DatabaseFragmentDoc, DocumentFragmentDoc, RelationFragmentDoc, AbortChatDocument, AddInsightToReportDocument, CancelOauthFlowDocument, CancelWorkspaceDeletionDocument, ConnectIntegrationDocument, ConsumePulseEventsDocument, ContinueImportedChatDocument, ContinueInterpretationDocument, CreateAgentDocument, CreateChatDocument, CreateDatabaseDocument, CreateDocumentDocument, CreateFeedbackDocument, CreateFolderDocument, CreateInsightDocument, CreateIntegrationDocument, CreateProjectDocument, CreateReportDocument, CreateTableDocument, CreateUserSkillFileDocument, CreateUserSkillFolderDocument, DeleteAgentDocument, DeleteAiProviderSettingDocument, DeleteArtifactDocument, DeleteChatDocument, DeleteDatabaseDocument, DeleteDocumentDocument, DeleteFolderDocument, DeleteInsightDocument, DeleteInsightsDocument, DeleteIntegrationDocument, DeleteProjectDocument, DeleteReportDocument, DeleteTableDocument, DeleteUserSkillFileDocument, DeleteUserSkillFolderDocument, DisconnectIntegrationDocument, DismissPulseEventDocument, ExecuteChatImportDocument, GenerateUploadUriDocument, PreviewChatImportDocument, ReanalyzeDocumentDocument, RefineAgentInstructionDocument, RefineSkillInstructionDocument, RefreshDatabaseSchemaDocument, RefreshInsightDocument, RegisterDesktopDeviceDocument, ReinterpretSourceDocument, ReinterpretSourcesOfuserDocument, RelocateInsightDocument, RemoveInsightFromReportDocument, ResetWorkspaceDocument, ResolvePulseEventDocument, ScheduleWorkspaceDeletionDocument, SendMessageDocument, SetDatabasePrimaryKeyDocument, SyncProjectDesktopBindingDocument, UpdateAgentDocument, UpdateArtifactNameDocument, UpdateChatDocument, UpdateDatabaseDocument, UpdateDocumentDocument, UpdateFolderDocument, UpdateInsightDocument, UpdateInsightInReportDocument, UpdateInsightThumbnailDocument, UpdateInterpDocument, UpdateLiveContextDocument, UpdateProjectDocument, UpdatePulseTriggerDocument, UpdateReportDocument, UpdateTableDocument, UpdateUserSkillFileDocument, UpdateUserSkillFolderDocument, UpsertAiProviderSettingDocument, AgentDocument, Agent_ChatsDocument, AgentsDocument, AiProviderSettingDocument, ArtifactDocument, Artifact_ChatDocument, Artifact_Chat_DesktopDeviceDocument, Artifact_Chat_InsightDocument, Artifact_Chat_ProjectDocument, Artifact_FileDocument, Artifact_MessageDocument, Artifact_Message_ChatDocument, Artifact_Message_ContentsDocument, Artifact_Message_FeedbackDocument, ArtifactsDocument, ChatDocument, Chat_AgentsDocument, Chat_ArtifactsDocument, Chat_DesktopDeviceDocument, Chat_DesktopDevice_DesktopBindingsDocument, Chat_InsightDocument, Chat_Insight_ReportMembersDocument, Chat_Insight_ThumbnailFileDocument, Chat_MessagesDocument, Chat_ProjectDocument, Chat_Project_DesktopBindingDocument, ChatMessageDocument, ChatMessage_ArtifactsDocument, ChatMessage_ChatDocument, ChatMessage_Chat_DesktopDeviceDocument, ChatMessage_Chat_InsightDocument, ChatMessage_Chat_ProjectDocument, ChatMessage_ContentsDocument, ChatMessage_FeedbackDocument, ChatMessagesDocument, ChatsDocument, DatabaseDocument, Database_EngineDocument, Database_Engine_CatalogDocument, Database_TablesDocument, DatabaseCatalogDocument, DatabaseCatalog_EngineDocument, DatabaseCatalogsDocument, DatabaseSchemaDocument, DatabasesDocument, DesktopDeviceDocument, DesktopDevice_ChatsDocument, DesktopDevice_DesktopBindingsDocument, DesktopDevicesDocument, DocumentDocument, Document_ContentsDocument, Document_FileDocument, Document_FormatDocument, Document_Format_CatalogDocument, Document_TablesDocument, DocumentCatalogDocument, DocumentCatalog_FormatDocument, DocumentCatalogsDocument, DocumentsDocument, ExportDocument, ExportWithInsightIdDocument, FeedItemDocument, FeedItem_ActionDocument, FeedItem_DataDocument, FeedItemsDocument, FileDocument, FileMetaDocument, FileUrlsDocument, FindFitTierDocument, FolderDocument, FoldersDocument, GetCapabilityDocument, GetDevAccessTokenDocument, GetLimitDocument, GetRemainingDocument, GetTokenUsageByModelDocument, GetTokenUsageHistoryDocument, GetTokenUsageStatusDocument, UsageWindowsStatusTypeFragmentDoc, GetTokenUsageStatus_WindowsDocument, GetTokenUsageStatus_Windows_DayDocument, GetTokenUsageStatus_Windows_FiveHourDocument, GetTokenUsageStatus_Windows_MonthDocument, GetTokenUsageStatus_Windows_WeekDocument, GetUsageDocument, InsightDocument, Insight_ChatDocument, Insight_Chat_DesktopDeviceDocument, Insight_Chat_ProjectDocument, Insight_ReportMembersDocument, Insight_ReportsDocument, Insight_ThumbnailFileDocument, InsightsDocument, IntegrationDocument, Integration_ProviderDocument, Integration_Provider_CatalogDocument, IntegrationCatalogDocument, IntegrationCatalog_ProviderDocument, IntegrationCatalogToolsDocument, IntegrationCatalogsDocument, IntegrationsDocument, InterpretationsDocument, LiveContextDocument, LiveContext_ItemsDocument, LiveContext_SourceDocument, LiveContext_Source_EvidencesDocument, LiveContextsDocument, LocalSandboxDeviceStatusesDocument, NotificationDocument, NotificationsDocument, NotificationsByReferenceDocument, PrivacyStatsDocument, ProjectDocument, Project_ChatsDocument, Project_DesktopBindingDocument, Project_DesktopBinding_DeviceDocument, ProjectsDocument, PulseAppSummaryDocument, PulseEventDocument, PulseEvent_IntegrationDocument, PulseEvent_Integration_ProviderDocument, PulseEventsDocument, PulseTriggerSettingsDocument, QueryDocument, QueryWithInsightIdDocument, QueryWithMessageIdDocument, ReportDocument, Report_InsightsDocument, Report_LayoutDocument, ReportsDocument, TableDocument, Table_DatabaseDocument, Table_Database_EngineDocument, Table_DocumentDocument, Table_Document_ContentsDocument, Table_Document_FileDocument, Table_Document_FormatDocument, Table_FromRelationsDocument, Table_ToRelationsDocument, TablesDocument, UserSkillFileDocument, UserSkillFilesDocument, UserSkillFolderDocument, UserSkillFoldersDocument, WorkspaceDeletionScheduleDocument, McpAuthUpdatesDocument, TokenUsageUpdatesDocument } from './chunk-ETPR6MV5.js';
6
6
  import { __commonJS, __toESM } from './chunk-5WRI5ZAA.js';
@@ -9007,9 +9007,12 @@ var CacheManager = class {
9007
9007
  */
9008
9008
  async invalidateQuery(operationName, variables) {
9009
9009
  const key = buildQueryKey(operationName, variables);
9010
+ await this.invalidateQueryKey(key);
9011
+ }
9012
+ async invalidateQueryKey(queryKey) {
9010
9013
  await this._db.transaction("rw", [this._db._queryResults, this._db._sync], async () => {
9011
- await this._db._queryResults.delete(key);
9012
- await this._db._sync.delete(getQueryFreshnessKey(key));
9014
+ await this._db._queryResults.delete(queryKey);
9015
+ await this._db._sync.delete(getQueryFreshnessKey(queryKey));
9013
9016
  });
9014
9017
  }
9015
9018
  /**
@@ -9704,6 +9707,7 @@ async function resolveRelationByReference(db, params) {
9704
9707
  }
9705
9708
 
9706
9709
  // src/store/sync-engine.ts
9710
+ var REVALIDATION_RETRY_DELAY_MS = 1e3;
9707
9711
  var SyncEngine = class {
9708
9712
  _db;
9709
9713
  _sse;
@@ -9720,6 +9724,8 @@ var SyncEngine = class {
9720
9724
  _subscriptionToQuery = /* @__PURE__ */ new Map();
9721
9725
  /** Last per-query revalidation timestamp to avoid refetch storms. */
9722
9726
  _lastRevalidatedAt = /* @__PURE__ */ new Map();
9727
+ /** Retry timers for recovery refetches that failed and need another attempt. */
9728
+ _revalidationRetryTimers = /* @__PURE__ */ new Map();
9723
9729
  /**
9724
9730
  * Last mutation/sync touch timestamp by entity type.
9725
9731
  * Used to detect stale cached query results on watch re-entry.
@@ -9757,27 +9763,24 @@ var SyncEngine = class {
9757
9763
  /**
9758
9764
  * Handle a full-resync signal from the server.
9759
9765
  *
9760
- * Clears all cached entities and query results, resets the sync cursor,
9761
- * then restarts the SSE connection so the client gets a fresh cursor.
9762
- * When SSE is available, active subscription-backed watchers are revalidated
9763
- * after the reconnect callback re-registers them with the server.
9764
- * Without SSE, revalidation happens immediately.
9766
+ * Clears all cached entities and query results, restarts delta sync, and
9767
+ * refetches active subscription-backed queries once so filtered connections
9768
+ * are rebuilt from source of truth instead of waiting for future delta events.
9765
9769
  */
9766
9770
  async handleFullResync() {
9767
9771
  this.stopSync();
9768
9772
  await this.clearAll();
9769
9773
  if (this._sse) {
9770
9774
  void this.startSync();
9771
- return;
9772
9775
  }
9773
9776
  await this._revalidateAllActiveSubscriptions();
9774
9777
  }
9775
9778
  /**
9776
- * Revalidate active subscription-backed queries after the SSE transport
9777
- * reconnects and re-registers them with the server.
9779
+ * Ordinary transport reconnects should recover from the sync cursor and
9780
+ * server-side subscription state without eagerly refetching every active query.
9778
9781
  */
9779
9782
  async handleTransportReconnect() {
9780
- await this._revalidateAllActiveSubscriptions();
9783
+ return;
9781
9784
  }
9782
9785
  /**
9783
9786
  * Process an incoming SSE sync event.
@@ -9840,8 +9843,15 @@ var SyncEngine = class {
9840
9843
  void this._revalidateSubscriptionIfStale(subscriptionDescriptor.id);
9841
9844
  const originalDispose = ref.dispose.bind(ref);
9842
9845
  ref.dispose = () => {
9846
+ const hasOtherActiveSubscription = this._hasOtherActiveSubscriptionForQueryKey(
9847
+ queryKey,
9848
+ subscriptionDescriptor.id
9849
+ );
9843
9850
  this._subscriptionToQueryKey.delete(subscriptionDescriptor.id);
9844
9851
  this._subscriptionToQuery.delete(subscriptionDescriptor.id);
9852
+ if (!hasOtherActiveSubscription) {
9853
+ this._clearRevalidationRetry(queryKey);
9854
+ }
9845
9855
  if (this._sse) {
9846
9856
  this._sse.unsubscribe(subscriptionDescriptor.id);
9847
9857
  }
@@ -10013,7 +10023,7 @@ var SyncEngine = class {
10013
10023
  if (!cached) return;
10014
10024
  const fetchedAt = await this._cache.getQueryFetchedAt(sub.queryKey, cached);
10015
10025
  if ((fetchedAt ?? cached.fetchedAt) >= touchedAt) return;
10016
- await this.query(sub.document, sub.variables, sub.operationName).catch(() => void 0);
10026
+ await this._revalidateSubscriptionQuery(sub, { force: true });
10017
10027
  }
10018
10028
  async _revalidateAllActiveSubscriptions() {
10019
10029
  await this._revalidateSubscriptions(Array.from(this._subscriptionToQuery.values()), { force: true });
@@ -10027,15 +10037,60 @@ var SyncEngine = class {
10027
10037
  pendingByQueryKey.set(sub.queryKey, sub);
10028
10038
  }
10029
10039
  if (pendingByQueryKey.size === 0) return;
10030
- for (const sub of pendingByQueryKey.values()) {
10031
- this._lastRevalidatedAt.set(sub.queryKey, now);
10032
- }
10033
10040
  await Promise.all(
10034
- Array.from(pendingByQueryKey.values()).map(
10035
- (sub) => this.query(sub.document, sub.variables, sub.operationName).catch(() => void 0)
10036
- )
10041
+ Array.from(pendingByQueryKey.values()).map((sub) => this._revalidateSubscriptionQuery(sub, options))
10037
10042
  );
10038
10043
  }
10044
+ async _revalidateSubscriptionQuery(subscription, options) {
10045
+ const startedAt = Date.now();
10046
+ this._lastRevalidatedAt.set(subscription.queryKey, startedAt);
10047
+ try {
10048
+ await this.query(subscription.document, subscription.variables, subscription.operationName);
10049
+ this._clearRevalidationRetry(subscription.queryKey);
10050
+ } catch {
10051
+ this._lastRevalidatedAt.delete(subscription.queryKey);
10052
+ await this._cache.invalidateQueryKey(subscription.queryKey).catch(() => void 0);
10053
+ if (options?.force || this._hasActiveSubscriptionForQueryKey(subscription.queryKey)) {
10054
+ this._scheduleRevalidationRetry(subscription.queryKey);
10055
+ }
10056
+ }
10057
+ }
10058
+ _scheduleRevalidationRetry(queryKey) {
10059
+ if (this._revalidationRetryTimers.has(queryKey)) {
10060
+ return;
10061
+ }
10062
+ const timer = setTimeout(() => {
10063
+ this._revalidationRetryTimers.delete(queryKey);
10064
+ const subscription = this._getActiveSubscriptionByQueryKey(queryKey);
10065
+ if (!subscription) {
10066
+ return;
10067
+ }
10068
+ void this._revalidateSubscriptionQuery(subscription, { force: true });
10069
+ }, REVALIDATION_RETRY_DELAY_MS);
10070
+ this._revalidationRetryTimers.set(queryKey, timer);
10071
+ }
10072
+ _clearRevalidationRetry(queryKey) {
10073
+ const timer = this._revalidationRetryTimers.get(queryKey);
10074
+ if (!timer) {
10075
+ return;
10076
+ }
10077
+ clearTimeout(timer);
10078
+ this._revalidationRetryTimers.delete(queryKey);
10079
+ }
10080
+ _getActiveSubscriptionByQueryKey(queryKey) {
10081
+ return Array.from(this._subscriptionToQuery.values()).find((sub) => sub.queryKey === queryKey);
10082
+ }
10083
+ _hasActiveSubscriptionForQueryKey(queryKey) {
10084
+ return this._getActiveSubscriptionByQueryKey(queryKey) !== void 0;
10085
+ }
10086
+ _hasOtherActiveSubscriptionForQueryKey(queryKey, subscriptionId) {
10087
+ for (const [activeSubscriptionId, subscription] of this._subscriptionToQuery.entries()) {
10088
+ if (activeSubscriptionId !== subscriptionId && subscription.queryKey === queryKey) {
10089
+ return true;
10090
+ }
10091
+ }
10092
+ return false;
10093
+ }
10039
10094
  _getActiveSubscriptionsForEntityType(entityType) {
10040
10095
  return Array.from(this._subscriptionToQuery.values()).filter((sub) => sub.entityType === entityType);
10041
10096
  }
@@ -10313,10 +10368,6 @@ function createLazySyncEngine(httpTransport, sseUrl, syncPolicyUrl, getToken, ge
10313
10368
  onFullResync: () => {
10314
10369
  realEngine?.handleFullResync().catch(() => {
10315
10370
  });
10316
- },
10317
- onReconnect: () => {
10318
- realEngine?.handleTransportReconnect().catch(() => {
10319
- });
10320
10371
  }
10321
10372
  });
10322
10373
  sseTransport = transport;
@@ -10573,6 +10624,9 @@ var DEFAULT_BASE_URL = "api.dvina.ai";
10573
10624
  var DB_INIT_TOKEN_POLL_INTERVAL_MS = 100;
10574
10625
  var DB_INIT_TOKEN_TIMEOUT_MS = 15e3;
10575
10626
  var LIFECYCLE_HINT_DEBOUNCE_MS = 250;
10627
+ function shouldRecoverConnections(hints) {
10628
+ return hints.has("network-restored") || hints.has("app-resumed");
10629
+ }
10576
10630
  function resolveGetToken(options) {
10577
10631
  if ("getToken" in options && options.getToken) {
10578
10632
  return options.getToken;
@@ -10683,17 +10737,27 @@ function createDvinaClient(options) {
10683
10737
  const billingSseUrl = `${billingBase}/subscriptions/stream`;
10684
10738
  const billing = new BillingClient({ billingHttpUrl, billingSseUrl, getToken, onError: options.onError });
10685
10739
  let lifecycleHintTimer;
10740
+ const pendingLifecycleHints = /* @__PURE__ */ new Set();
10741
+ const recoverConnections = () => {
10742
+ recoverableSyncEngine.reconnectActiveSync();
10743
+ chatStream.reconnectAll();
10744
+ wsTransport?.terminate();
10745
+ billing.reconnectAll();
10746
+ };
10686
10747
  const lifecycle = {
10687
- hint(_reason) {
10748
+ hint(reason) {
10749
+ pendingLifecycleHints.add(reason);
10688
10750
  if (lifecycleHintTimer) {
10689
10751
  return;
10690
10752
  }
10691
10753
  lifecycleHintTimer = setTimeout(() => {
10692
10754
  lifecycleHintTimer = void 0;
10693
- recoverableSyncEngine.reconnectActiveSync();
10694
- chatStream.reconnectAll();
10695
- wsTransport?.terminate();
10696
- billing.reconnectAll();
10755
+ const hints = new Set(pendingLifecycleHints);
10756
+ pendingLifecycleHints.clear();
10757
+ if (!shouldRecoverConnections(hints)) {
10758
+ return;
10759
+ }
10760
+ recoverConnections();
10697
10761
  }, LIFECYCLE_HINT_DEBOUNCE_MS);
10698
10762
  }
10699
10763
  };
@@ -22871,5 +22935,5 @@ var DvinaSdk = class extends Request {
22871
22935
  };
22872
22936
 
22873
22937
  export { AbortChatMutation, Action, AddInsightToReportMutation, Agent, AgentConnection, AgentQuery, AgentSubBuilder, Agent_ChatsQuery, AgentsQuery, AiProviderSettingQuery, Artifact, ArtifactConnection, ArtifactQuery, ArtifactSubBuilder, Artifact_ChatQuery, Artifact_Chat_DesktopDeviceQuery, Artifact_Chat_InsightQuery, Artifact_Chat_ProjectQuery, Artifact_FileQuery, Artifact_MessageQuery, Artifact_Message_ChatQuery, Artifact_Message_ContentsQuery, Artifact_Message_FeedbackQuery, ArtifactsQuery, AudioEventOutput, CancelOauthFlowMutation, CancelWorkspaceDeletionMutation, Candidate, CandidateEvidence, Chat, ChatConnection, ChatImportExecuteOutput, ChatImportPreviewOutput, ChatMessage, ChatMessageConnection, ChatMessageQuery, ChatMessageSubBuilder, ChatMessage_ArtifactsQuery, ChatMessage_ChatQuery, ChatMessage_Chat_DesktopDeviceQuery, ChatMessage_Chat_InsightQuery, ChatMessage_Chat_ProjectQuery, ChatMessage_ContentsQuery, ChatMessage_FeedbackQuery, ChatMessagesQuery, ChatQuery, ChatSubBuilder, ChatTitleEventOutput, Chat_AgentsQuery, Chat_ArtifactsQuery, Chat_DesktopDeviceQuery, Chat_DesktopDevice_DesktopBindingsQuery, Chat_InsightQuery, Chat_Insight_ReportMembersQuery, Chat_Insight_ThumbnailFileQuery, Chat_MessagesQuery, Chat_ProjectQuery, Chat_Project_DesktopBindingQuery, ChatsQuery, ConnectIntegrationMutation, ConsumePulseEventsMutation, ContentBlock, ContentMask, ContinueImportedChatMutation, ContinueInterpretationMutation, CreateAgentMutation, CreateChatMutation, CreateDatabaseMutation, CreateDocumentMutation, CreateFeedbackMutation, CreateFolderMutation, CreateInsightMutation, CreateIntegrationMutation, CreateIntegrationOutput, CreateProjectMutation, CreateReportMutation, CreateTableMutation, CreateUserSkillFileMutation, CreateUserSkillFolderMutation, CubeModel, DB_ENTITY_SCHEMA, Database, DatabaseCatalog, DatabaseCatalogConnection, DatabaseCatalogQuery, DatabaseCatalogSubBuilder, DatabaseCatalog_EngineQuery, DatabaseCatalogsQuery, DatabaseConnection, DatabaseEngine, DatabaseQuery, DatabaseSchemaQuery, DatabaseSubBuilder, Database_EngineQuery, Database_Engine_CatalogQuery, Database_TablesQuery, DatabasesQuery, DeepAnalysisUsage, DeferredDvinaQueryRef, DeleteAgentMutation, DeleteAiProviderSettingMutation, DeleteArtifactMutation, DeleteChatMutation, DeleteDatabaseMutation, DeleteDocumentMutation, DeleteFolderMutation, DeleteInsightMutation, DeleteInsightsMutation, DeleteIntegrationMutation, DeleteProjectMutation, DeleteReportMutation, DeleteTableMutation, DeleteUserSkillFileMutation, DeleteUserSkillFolderMutation, DesktopDevice, DesktopDeviceConnection, DesktopDeviceQuery, DesktopDeviceSubBuilder, DesktopDevice_ChatsQuery, DesktopDevice_DesktopBindingsQuery, DesktopDevicesQuery, DevAccessTokenOutput, DexieLiveQueryRef, DisconnectIntegrationMutation, DismissPulseEventMutation, Document, DocumentCatalog, DocumentCatalogConnection, DocumentCatalogQuery, DocumentCatalogSubBuilder, DocumentCatalog_FormatQuery, DocumentCatalogsQuery, DocumentConnection, DocumentContent, DocumentFormat, DocumentQuery, DocumentSubBuilder, Document_ContentsQuery, Document_FileQuery, Document_FormatQuery, Document_Format_CatalogQuery, Document_TablesQuery, DocumentsQuery, DvinaDatabase, DvinaModel, DvinaSdk, Evidence, ExecuteChatImportMutation, ExportQuery, ExportWithInsightIdQuery, FailedSyncEventIngestion, FeedArtifactData, FeedConnection, FeedDatabaseData, FeedDocumentData, FeedInsightData, FeedIntegrationData, FeedItem, FeedItemGenerated, FeedItemQuery, FeedItemSubBuilder, FeedItem_ActionQuery, FeedItem_DataQuery, FeedItemsQuery, FeedLiveContextData, FeedProjectData, FeedPulseData, FeedSendMessageAction, Feedback, File, FileMetaQuery, FileModel, FileQuery, FileUrlsQuery, FinalContentEventOutput, FindFitTierQuery, Folder, FolderConnection, FolderQuery, FoldersQuery, GenerateUploadUriMutation, GetCapabilityQuery, GetDevAccessTokenQuery, GetLimitQuery, GetRemainingQuery, GetTokenUsageByModelQuery, GetTokenUsageHistoryQuery, GetTokenUsageStatusQuery, GetTokenUsageStatus_WindowsQuery, GetTokenUsageStatus_Windows_DayQuery, GetTokenUsageStatus_Windows_FiveHourQuery, GetTokenUsageStatus_Windows_MonthQuery, GetTokenUsageStatus_Windows_WeekQuery, GetUsageQuery, ImportedChatSummaryOutput, InferenceRequestAudit, Insight, InsightConnection, InsightQuery, InsightSubBuilder, Insight_ChatQuery, Insight_Chat_DesktopDeviceQuery, Insight_Chat_ProjectQuery, Insight_ReportMembersQuery, Insight_ReportsQuery, Insight_ThumbnailFileQuery, InsightsQuery, Integration, IntegrationCatalog, IntegrationCatalogConnection, IntegrationCatalogQuery, IntegrationCatalogSubBuilder, IntegrationCatalogToolsQuery, IntegrationCatalog_ProviderQuery, IntegrationCatalogsQuery, IntegrationConnection, IntegrationProvider, IntegrationQuery, IntegrationSubBuilder, Integration_ProviderQuery, Integration_Provider_CatalogQuery, IntegrationsQuery, Interpretation, InterpretationConnection, InterpretationsQuery, Invocation, LiveContext, LiveContextConnection, LiveContextQuery, LiveContextSubBuilder, LiveContext_ItemsQuery, LiveContext_SourceQuery, LiveContext_Source_EvidencesQuery, LiveContextsQuery, LocalSandboxDeviceStatusModel, LocalSandboxDeviceStatusesQuery, MUTATION_CACHE_RULES, MappedDvinaQueryRef, McpAuthUpdateModel, McpAuthUpdatesSubscription, McpClientInformation, McpCodeVerifier, McpServer, McpTokens, McpTool, MessageEndEventOutput, MessageStartEventOutput, ModelTokenUsage, Notification, NotificationConnection, NotificationQuery, NotificationsByReferenceQuery, NotificationsQuery, PRIMARY_KEY_CONFIG, PreviewChatImportMutation, PrivacyStats, PrivacyStatsQuery, ProgressSummaryEventOutput, Project, ProjectConnection, ProjectDesktopBinding, ProjectQuery, ProjectSubBuilder, Project_ChatsQuery, Project_DesktopBindingQuery, Project_DesktopBinding_DeviceQuery, ProjectsQuery, PulseAppSummaryModel, PulseAppSummaryQuery, PulseEvent, PulseEventConnection, PulseEventQuery, PulseEventSubBuilder, PulseEvent_IntegrationQuery, PulseEvent_Integration_ProviderQuery, PulseEventsQuery, PulseTriggerSettingModel, PulseTriggerSettingsQuery, QueryQuery, QueryWithInsightIdQuery, QueryWithMessageIdQuery, ReanalyzeDocumentMutation, ReasoningEventOutput, RefineAgentInstructionMutation, RefineSkillInstructionMutation, RefreshDatabaseSchemaMutation, RefreshInsightMutation, RegisterDesktopDeviceMutation, ReinterpretSourceMutation, ReinterpretSourcesOfuserMutation, Relation, RelocateInsightMutation, RemoveInsightFromReportMutation, Report, ReportConnection, ReportMember, ReportQuery, ReportSubBuilder, Report_InsightsQuery, Report_LayoutQuery, ReportsQuery, ResetWorkspaceMutation, ResolvePulseEventMutation, ResolvedFileUrl, ScheduleWorkspaceDeletionMutation, SendMessageMutation, SetDatabasePrimaryKeyMutation, StreamEventSchemaAnchor, StreamMessageContentOutput, StreamMessageOutput, SyncEngine, SyncEvent, SyncEventCursor, SyncProjectDesktopBindingMutation, TABLE_TO_TYPENAME, TYPENAME_TO_TABLE, Table, TableConnection, TableQuery, TableSubBuilder, Table_DatabaseQuery, Table_Database_EngineQuery, Table_DocumentQuery, Table_Document_ContentsQuery, Table_Document_FileQuery, Table_Document_FormatQuery, Table_FromRelationsQuery, Table_ToRelationsQuery, TablesQuery, TextBlockEventOutput, TextDeltaEventOutput, TokenUsage, TokenUsageUpdatesSubscription, ToolInputDeltaEventOutput, ToolResultArtifactOutput, ToolResultEventOutput, ToolStartEventOutput, UpdateAgentMutation, UpdateArtifactNameMutation, UpdateChatMutation, UpdateDatabaseMutation, UpdateDocumentMutation, UpdateFolderMutation, UpdateInsightInReportMutation, UpdateInsightMutation, UpdateInsightThumbnailMutation, UpdateInterpMutation, UpdateLiveContextMutation, UpdateProjectMutation, UpdatePulseTriggerMutation, UpdateReportMutation, UpdateTableMutation, UpdateUserSkillFileMutation, UpdateUserSkillFolderMutation, UpsertAiProviderSettingMutation, UsageMetaOutput, UsageStatus, UsageWindowsStatusType, UserAiProviderSetting, UserSkillFile, UserSkillFileModel, UserSkillFileQuery, UserSkillFilesQuery, UserSkillFolder, UserSkillFolderModel, UserSkillFolderQuery, UserSkillFoldersQuery, WidgetBlockCompleteEventOutput, WidgetBlockErrorEventOutput, WidgetBlockStartEventOutput, WidgetHtmlDeltaEventOutput, WindowDetailType, WorkspaceDeleteSchedule, WorkspaceDeletionScheduleQuery, closeDatabase, createChatStreamClient, createDvinaClient, createLazySyncEngine, createSseTransport, createWsTransport, deleteDatabase, getOrCreateDatabase, reconstructConnectionNodes, reconstructEntity, uploadFile };
22874
- //# sourceMappingURL=chunk-IM7TFRLL.js.map
22875
- //# sourceMappingURL=chunk-IM7TFRLL.js.map
22938
+ //# sourceMappingURL=chunk-6PAEAOGQ.js.map
22939
+ //# sourceMappingURL=chunk-6PAEAOGQ.js.map