@dvina/sdk 4.1.40 → 4.1.46

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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkRVFJ54CF_cjs = require('../../chunk-RVFJ54CF.cjs');
3
+ var chunkMU7OHEDQ_cjs = require('../../chunk-MU7OHEDQ.cjs');
4
4
  require('../../chunk-342BFYZZ.cjs');
5
5
  require('../../chunk-UELAE75E.cjs');
6
6
  require('../../chunk-2J5WONKO.cjs');
@@ -147,10 +147,10 @@ function hasDispose(value) {
147
147
  function provideDvina(optionsOrFactory) {
148
148
  return core.makeEnvironmentProviders([
149
149
  {
150
- provide: chunkRVFJ54CF_cjs.DvinaSdk,
150
+ provide: chunkMU7OHEDQ_cjs.DvinaSdk,
151
151
  useFactory: () => {
152
152
  const options = typeof optionsOrFactory === "function" ? optionsOrFactory() : optionsOrFactory;
153
- return new chunkRVFJ54CF_cjs.DvinaSdk(options);
153
+ return new chunkMU7OHEDQ_cjs.DvinaSdk(options);
154
154
  }
155
155
  }
156
156
  ]);
@@ -1,5 +1,5 @@
1
1
  import { Signal, DestroyRef, EnvironmentProviders } from '@angular/core';
2
- import { D as DvinaSdkOptions } from '../../client-cS9hpg7B.cjs';
2
+ import { D as DvinaSdkOptions } from '../../client-BRBEtlwV.cjs';
3
3
  import { D as DvinaAsyncRef } from '../../types-Chg8ASmf.cjs';
4
4
  import '../../error-CsVoUTY8.cjs';
5
5
  import '../../sync-engine-9n6C9179.cjs';
@@ -1,5 +1,5 @@
1
1
  import { Signal, DestroyRef, EnvironmentProviders } from '@angular/core';
2
- import { D as DvinaSdkOptions } from '../../client-D8xvFccR.js';
2
+ import { D as DvinaSdkOptions } from '../../client-NyQpHo5O.js';
3
3
  import { D as DvinaAsyncRef } from '../../types-Chg8ASmf.js';
4
4
  import '../../error-CsVoUTY8.js';
5
5
  import '../../sync-engine-Ct29d1al.js';
@@ -1,4 +1,4 @@
1
- import { DvinaSdk } from '../../chunk-MHSOVM7J.js';
1
+ import { DvinaSdk } from '../../chunk-MBMJJ2BB.js';
2
2
  import '../../chunk-KEM6SUTS.js';
3
3
  import '../../chunk-PDM2KR7T.js';
4
4
  import '../../chunk-WX7EFPHT.js';
@@ -10569,10 +10569,14 @@ var RealtimeEventRef = class {
10569
10569
  }
10570
10570
  };
10571
10571
  var DvinaEventsClient = class {
10572
- constructor(controller) {
10572
+ constructor(controller, snapshotCache) {
10573
10573
  this.controller = controller;
10574
+ this.snapshotCache = snapshotCache;
10574
10575
  }
10575
10576
  refs = /* @__PURE__ */ new Map();
10577
+ snapshots = /* @__PURE__ */ new Map();
10578
+ hydratedTopics = /* @__PURE__ */ new Set();
10579
+ hydrationPromises = /* @__PURE__ */ new Map();
10576
10580
  activeChats() {
10577
10581
  return this.topic("active-chats");
10578
10582
  }
@@ -10583,13 +10587,12 @@ var DvinaEventsClient = class {
10583
10587
  return this.topic("desktop-device-presence");
10584
10588
  }
10585
10589
  dispatch(event) {
10586
- const refs = this.refs.get(event.topic);
10587
- if (!refs) {
10588
- return;
10589
- }
10590
- const value = { type: event.type, data: event.data };
10591
- for (const ref of refs) {
10592
- ref.emit(value);
10590
+ this.hydratedTopics.add(event.topic);
10591
+ this.snapshots.set(event.topic, event);
10592
+ this.emit(event);
10593
+ if (event.type === "snapshot") {
10594
+ void this.snapshotCache?.write(event.topic, event.data).catch(() => {
10595
+ });
10593
10596
  }
10594
10597
  }
10595
10598
  topic(topic) {
@@ -10609,14 +10612,55 @@ var DvinaEventsClient = class {
10609
10612
  }
10610
10613
  });
10611
10614
  refs.add(ref);
10615
+ const snapshot = this.snapshots.get(topic);
10616
+ if (snapshot) {
10617
+ ref.emit({ type: snapshot.type, data: snapshot.data });
10618
+ } else {
10619
+ void this.hydrate(topic);
10620
+ }
10612
10621
  if (wasEmpty) {
10613
10622
  this.controller.subscribe(topic);
10614
10623
  }
10615
10624
  return ref;
10616
10625
  }
10626
+ emit(event) {
10627
+ const refs = this.refs.get(event.topic);
10628
+ if (!refs) {
10629
+ return;
10630
+ }
10631
+ const value = { type: event.type, data: event.data };
10632
+ for (const ref of refs) {
10633
+ ref.emit(value);
10634
+ }
10635
+ }
10636
+ hydrate(topic) {
10637
+ if (!this.snapshotCache || this.hydratedTopics.has(topic)) {
10638
+ return Promise.resolve();
10639
+ }
10640
+ const existing = this.hydrationPromises.get(topic);
10641
+ if (existing) {
10642
+ return existing;
10643
+ }
10644
+ const hydration = this.snapshotCache.read(topic).then((data) => {
10645
+ if (this.hydratedTopics.has(topic)) {
10646
+ return;
10647
+ }
10648
+ if (data === void 0) {
10649
+ return;
10650
+ }
10651
+ const snapshot = { data, topic, type: "snapshot" };
10652
+ this.snapshots.set(topic, snapshot);
10653
+ this.emit(snapshot);
10654
+ }).catch(() => {
10655
+ }).finally(() => {
10656
+ this.hydrationPromises.delete(topic);
10657
+ });
10658
+ this.hydrationPromises.set(topic, hydration);
10659
+ return hydration;
10660
+ }
10617
10661
  };
10618
- function createDvinaEvents(controller) {
10619
- return new DvinaEventsClient(controller);
10662
+ function createDvinaEvents(controller, snapshotCache) {
10663
+ return new DvinaEventsClient(controller, snapshotCache);
10620
10664
  }
10621
10665
 
10622
10666
  // src/upload.ts
@@ -10773,6 +10817,7 @@ var DEFAULT_BASE_URL = "api.dvina.ai";
10773
10817
  var DB_INIT_TOKEN_POLL_INTERVAL_MS = 100;
10774
10818
  var DB_INIT_TOKEN_TIMEOUT_MS = 15e3;
10775
10819
  var LIFECYCLE_HINT_DEBOUNCE_MS = 250;
10820
+ var ACTIVE_TABS_SNAPSHOT_CACHE_KEY = "realtimeSnapshot:active-tabs";
10776
10821
  function shouldRecoverConnections(hints) {
10777
10822
  return hints.has("network-restored") || hints.has("app-resumed") || hints.has("became-active");
10778
10823
  }
@@ -10895,10 +10940,29 @@ function createDvinaClient(options) {
10895
10940
  }
10896
10941
  );
10897
10942
  const recoverableSyncEngine = syncEngine;
10898
- events = createDvinaEvents({
10899
- subscribe: (topic) => recoverableSyncEngine.subscribeRealtimeEvent(topic),
10900
- unsubscribe: (topic) => recoverableSyncEngine.unsubscribeRealtimeEvent(topic)
10901
- });
10943
+ events = createDvinaEvents(
10944
+ {
10945
+ subscribe: (topic) => recoverableSyncEngine.subscribeRealtimeEvent(topic),
10946
+ unsubscribe: (topic) => recoverableSyncEngine.unsubscribeRealtimeEvent(topic)
10947
+ },
10948
+ {
10949
+ async read(topic) {
10950
+ if (topic !== "active-tabs") {
10951
+ return void 0;
10952
+ }
10953
+ const entry = await getDb().then((database) => database._sync.get(ACTIVE_TABS_SNAPSHOT_CACHE_KEY));
10954
+ return entry?.value;
10955
+ },
10956
+ async write(topic, data) {
10957
+ if (topic !== "active-tabs") {
10958
+ return;
10959
+ }
10960
+ await getDb().then(
10961
+ (database) => database._sync.put({ key: ACTIVE_TABS_SNAPSHOT_CACHE_KEY, value: data })
10962
+ );
10963
+ }
10964
+ }
10965
+ );
10902
10966
  const request = async (document2, variables, _options) => {
10903
10967
  return syncEngine.query(document2, variables);
10904
10968
  };
@@ -23470,5 +23534,5 @@ var DvinaSdk = class extends Request {
23470
23534
  };
23471
23535
 
23472
23536
  export { AbortChatMutation, Action, AddInsightToReportMutation, AddMcpServerMutation, 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, CloseActiveTabsMutation, ConnectIntegrationMutation, ConsumePulseEventsMutation, ContentBlock, ContentBlockAgentOutput, ContentMask, ContextUsageEventOutput, 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, DeleteSavedAiProviderModelMutation, 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, InterruptEventOutput, Invocation, LegacyCodeMigratedChatSummaryOutput, LegacyCodeMigrationOutput, LiveContext, LiveContextConnection, LiveContextQuery, LiveContextSubBuilder, LiveContext_ItemsQuery, LiveContext_SourceQuery, LiveContext_Source_EvidencesQuery, LiveContextsQuery, LocalSandboxDeviceStatusModel, LocalSandboxDeviceStatusesQuery, MUTATION_CACHE_RULES, ManagedChatModelsQuery, MappedDvinaQueryRef, McpAuthUpdateModel, McpAuthUpdatesSubscription, McpClientInformation, McpCodeVerifier, McpServer, McpServerTestOutput, McpTokens, McpTool, MessageEndEventOutput, MessageStartEventOutput, MigrateLegacyCodeChatsMutation, ModelTokenUsage, Notification, NotificationConnection, NotificationQuery, NotificationsByReferenceQuery, NotificationsQuery, OpenActiveTabMutation, PRIMARY_KEY_CONFIG, PreviewChatImportMutation, PrivacyStats, PrivacyStatsOutput, PrivacyStatsQuery, PrivateMcpServersQuery, 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, RemoveMcpServerMutation, Report, ReportConnection, ReportMember, ReportQuery, ReportSubBuilder, Report_InsightsQuery, Report_LayoutQuery, ReportsQuery, ResetWorkspaceMutation, ResolvePulseEventMutation, ResolvedFileUrl, ResumeMessageMutation, ScheduleWorkspaceDeletionMutation, SendMessageMutation, SetDatabasePrimaryKeyMutation, SkillCatalogItem, SkillCatalogQuery, 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, TestMcpServerConnectionMutation, TestMcpServerMutation, 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, UpsertWorkspaceAiModelMutation, UsageMetaOutput, UsageStatus, UsageWindowsStatusType, UserAiProviderSetting, UserSkillFile, UserSkillFileModel, UserSkillFileQuery, UserSkillFilesQuery, UserSkillFolder, UserSkillFolderModel, UserSkillFolderQuery, UserSkillFoldersQuery, WidgetBlockCompleteEventOutput, WidgetBlockErrorEventOutput, WidgetBlockStartEventOutput, WidgetHtmlDeltaEventOutput, WindowDetailType, WorkspaceAiModelQuery, WorkspaceAiModelSetting, WorkspaceDeleteSchedule, WorkspaceDeletionScheduleQuery, closeDatabase, createChatStreamClient, createDvinaClient, createDvinaEvents, createLazySyncEngine, createSseTransport, createWsTransport, deleteDatabase, getOrCreateDatabase, reconstructConnectionNodes, reconstructEntity, uploadFile };
23473
- //# sourceMappingURL=chunk-MHSOVM7J.js.map
23474
- //# sourceMappingURL=chunk-MHSOVM7J.js.map
23537
+ //# sourceMappingURL=chunk-MBMJJ2BB.js.map
23538
+ //# sourceMappingURL=chunk-MBMJJ2BB.js.map