@pmate/chat-sdk 0.12.0-next.7 → 0.12.0-next.71

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 (105) hide show
  1. package/README.md +170 -81
  2. package/lib/advanced.d.ts +10 -0
  3. package/lib/advanced.js +10 -0
  4. package/lib/chat.d.ts +5 -0
  5. package/lib/chat.js +11 -0
  6. package/lib/chatContract.d.ts +148 -0
  7. package/lib/chatContract.js +1 -0
  8. package/lib/chatError.d.ts +11 -0
  9. package/lib/chatError.js +13 -0
  10. package/lib/chatTypes.d.ts +121 -0
  11. package/lib/chatTypes.js +1 -0
  12. package/lib/commands.d.ts +20 -0
  13. package/lib/commands.js +12 -0
  14. package/lib/components/ChatInputDesktop.js +5 -4
  15. package/lib/components/ChatInputMobile.js +5 -4
  16. package/lib/components/CommandMenu.d.ts +15 -0
  17. package/lib/components/CommandMenu.js +10 -0
  18. package/lib/credentials.d.ts +26 -0
  19. package/lib/credentials.js +110 -0
  20. package/lib/fileMetadata.d.ts +9 -0
  21. package/lib/fileMetadata.js +18 -0
  22. package/lib/framework.d.ts +11 -0
  23. package/lib/framework.js +12 -0
  24. package/lib/history.d.ts +4 -0
  25. package/lib/history.js +8 -0
  26. package/lib/hooks/useChatSnapshot.d.ts +4 -0
  27. package/lib/hooks/useChatSnapshot.js +9 -0
  28. package/lib/hooks/useComposerSuggestions.d.ts +50 -0
  29. package/lib/hooks/useComposerSuggestions.js +70 -0
  30. package/lib/index.d.ts +5 -0
  31. package/lib/index.js +5 -0
  32. package/lib/internal/chatEngine.d.ts +131 -0
  33. package/lib/internal/chatEngine.js +280 -0
  34. package/lib/internal/chatRegistry.d.ts +4 -0
  35. package/lib/internal/chatRegistry.js +4 -0
  36. package/lib/internal/createPublicChat.d.ts +4 -0
  37. package/lib/internal/createPublicChat.js +52 -0
  38. package/lib/messageView.d.ts +6 -0
  39. package/lib/messageView.js +103 -0
  40. package/lib/runtime/batchedReadIndex.d.ts +16 -3
  41. package/lib/runtime/batchedReadIndex.js +50 -4
  42. package/lib/runtime/cachedMessage.d.ts +12 -0
  43. package/lib/runtime/cachedMessage.js +18 -0
  44. package/lib/runtime/chatClient.d.ts +2 -0
  45. package/lib/runtime/chatClient.js +8 -3
  46. package/lib/runtime/chatError.d.ts +3 -0
  47. package/lib/runtime/chatError.js +15 -0
  48. package/lib/runtime/chatSession.d.ts +127 -13
  49. package/lib/runtime/chatSession.js +727 -40
  50. package/lib/runtime/connectivity.d.ts +4 -0
  51. package/lib/runtime/connectivity.js +8 -0
  52. package/lib/runtime/conversationDirectory.d.ts +37 -0
  53. package/lib/runtime/conversationDirectory.js +116 -0
  54. package/lib/runtime/conversationRead.d.ts +13 -0
  55. package/lib/runtime/conversationRead.js +34 -0
  56. package/lib/runtime/conversationReading.d.ts +28 -0
  57. package/lib/runtime/conversationReading.js +47 -0
  58. package/lib/runtime/createChat.d.ts +11 -7
  59. package/lib/runtime/createChat.js +46 -23
  60. package/lib/runtime/durableSender.d.ts +97 -14
  61. package/lib/runtime/durableSender.js +786 -71
  62. package/lib/runtime/groupClient.d.ts +76 -0
  63. package/lib/runtime/groupClient.js +325 -0
  64. package/lib/runtime/index.d.ts +7 -0
  65. package/lib/runtime/index.js +5 -0
  66. package/lib/runtime/messageClient.d.ts +35 -8
  67. package/lib/runtime/messageClient.js +364 -66
  68. package/lib/runtime/messageControls.d.ts +19 -0
  69. package/lib/runtime/messageControls.js +44 -0
  70. package/lib/runtime/messageLaunch.d.ts +44 -0
  71. package/lib/runtime/messageLaunch.js +137 -0
  72. package/lib/runtime/messageQuotes.d.ts +3 -0
  73. package/lib/runtime/messageQuotes.js +17 -0
  74. package/lib/runtime/messageReaders.d.ts +12 -1
  75. package/lib/runtime/messageReaders.js +67 -3
  76. package/lib/runtime/messageStore.d.ts +40 -2
  77. package/lib/runtime/messageStore.js +227 -11
  78. package/lib/runtime/messageTimeline.d.ts +50 -0
  79. package/lib/runtime/messageTimeline.js +120 -0
  80. package/lib/runtime/outboxSchema.d.ts +5 -0
  81. package/lib/runtime/outboxSchema.js +59 -0
  82. package/lib/runtime/outgoingContent.d.ts +89 -0
  83. package/lib/runtime/outgoingContent.js +113 -0
  84. package/lib/runtime/readBatchJournal.d.ts +35 -0
  85. package/lib/runtime/readBatchJournal.js +210 -0
  86. package/lib/runtime/readCounts.d.ts +15 -1
  87. package/lib/runtime/readCounts.js +97 -9
  88. package/lib/runtime/readIndex.d.ts +68 -7
  89. package/lib/runtime/readIndex.js +460 -22
  90. package/lib/runtime/readSchema.d.ts +2 -0
  91. package/lib/runtime/readSchema.js +58 -0
  92. package/lib/runtime/readSync.d.ts +1 -0
  93. package/lib/runtime/readSync.js +26 -9
  94. package/lib/runtime/readingClient.d.ts +19 -0
  95. package/lib/runtime/readingClient.js +131 -19
  96. package/lib/runtime/readingContent.d.ts +5 -0
  97. package/lib/runtime/readingContent.js +23 -0
  98. package/lib/runtime/responseCache.d.ts +59 -0
  99. package/lib/runtime/responseCache.js +232 -0
  100. package/lib/runtime/socialReadClient.d.ts +4 -2
  101. package/lib/runtime/socialReadClient.js +12 -8
  102. package/lib/runtime/voiceUpload.d.ts +2 -0
  103. package/lib/runtime/voiceUpload.js +27 -0
  104. package/lib/types/chatInput.d.ts +3 -0
  105. package/package.json +27 -2
@@ -7,9 +7,16 @@ export type IndexedReadMessage = {
7
7
  mentions: string[];
8
8
  readPolicy: "visible" | "explicit";
9
9
  recalled: boolean;
10
- /** Cached payload is retained so an offline reload can render the message. */
10
+ /** Legacy standalone readers may retain payloads; unified sessions use the message store. */
11
11
  payload: unknown;
12
+ /** Body-free control classification retained by metadata-only reading indexes. */
13
+ readingControl?: boolean;
12
14
  };
15
+ /** Retain read semantics without a second durable copy of message bodies. */
16
+ export declare function readingMetadata<T extends {
17
+ appId: string;
18
+ threads: IndexedReadThread[];
19
+ }>(state: T): T;
13
20
  export type ReadingOperation = {
14
21
  operationId: string;
15
22
  threadId: string;
@@ -64,6 +71,7 @@ export declare function installReadSnapshot(current: ReadIndexState, snapshot: R
64
71
  export declare function applyReadChange(current: ReadIndexState, change: ReadChange): ReadIndexState;
65
72
  /** Persist observations even if the message arrived before its Sequence metadata. */
66
73
  export declare function recordReadIntent(current: ReadIndexState, intent: ObservedReadIntent): ReadIndexState;
74
+ export declare function resolveObservedReads(current: ReadIndexState): ReadIndexState;
67
75
  /** Called only for a message the visible viewport actually reached. */
68
76
  export declare function recordVisibleRead(current: ReadIndexState, threadId: string, messageId: string, operationId: string): ReadIndexState;
69
77
  export declare function recordExplicitRead(current: ReadIndexState, threadId: string, messageId: string, operationId: string): ReadIndexState;
@@ -72,32 +80,85 @@ export declare function coalesceReadOperations(current: ReadIndexState): (Readin
72
80
  operationIds: string[];
73
81
  })[];
74
82
  /** Counts are over the indexed message coverage, not an estimate of missing history. */
75
- export declare function unreadInThread(state: ReadIndexState, threadId: string): {
83
+ export declare function unreadInThread(state: ReadIndexState, threadId: string, hidden?: ReadonlyMap<string, ReadonlySet<string>>): {
76
84
  unreadMessageCount: number;
77
85
  unreadMentionCount: number;
78
86
  badgeCount: number;
79
87
  };
88
+ export type ReadIndexVersions = Readonly<Record<string, number>>;
89
+ export type ReadIndexTransform = (current: ReadIndexState, versions?: ReadIndexVersions) => ReadIndexState;
90
+ export declare function assertReadIndexVersions(expected: ReadIndexVersions, current?: ReadIndexVersions, teamId?: string): void;
91
+ /** Remove only the withdrawn team's original sources, logical conversations and
92
+ * queued observations. Other teams' pending operations must survive. */
93
+ export declare function removeReadTeam(state: ReadIndexState, teamId: string, knownThreadIds?: readonly string[]): ReadIndexState;
94
+ /** Internal hint for typed reading observations; arbitrary transforms omit it. */
95
+ export type ReadObservationScope = {
96
+ base: ReadIndexState;
97
+ targets: readonly {
98
+ threadId: string;
99
+ messageId: string;
100
+ }[];
101
+ };
80
102
  export interface ReadIndexPersistence {
81
103
  load(appId: string, profileId: string): Promise<ReadIndexState | undefined>;
104
+ loadVersioned?(appId: string, profileId: string): Promise<{
105
+ state: ReadIndexState | undefined;
106
+ versions: ReadIndexVersions;
107
+ }>;
108
+ loadVersions?(appId: string, profileId: string): Promise<ReadIndexVersions>;
109
+ invalidateTeam?(appId: string, profileId: string, teamId: string, version: number, knownThreadIds?: readonly string[]): Promise<ReadIndexState>;
82
110
  /** Transform and persist atomically; UI publishes only the committed result. */
83
- update(appId: string, profileId: string, transform: (current: ReadIndexState) => ReadIndexState): Promise<ReadIndexState>;
111
+ update(appId: string, profileId: string, transform: ReadIndexTransform, observation?: ReadObservationScope): Promise<ReadIndexState>;
84
112
  }
85
- /** Dexie preserves the legacy database/store and outbound [appId, profileId] keys. */
113
+ /** Preserves the database and logical keys; store renaming fences old format writers. */
86
114
  export declare class IndexedDbReadIndex implements ReadIndexPersistence {
87
115
  private storageScope?;
116
+ private migrateLegacy;
117
+ private metadataOnly;
88
118
  private database;
89
119
  private profiles;
120
+ private threadRows;
121
+ private messageRows;
122
+ private positionRows;
123
+ private normalizedStates;
124
+ private orderedStates;
125
+ private legacyClean;
126
+ private observationMessages;
127
+ private versions;
90
128
  private closed;
91
- constructor(factory?: IDBFactory, name?: string, storageScope?: string | undefined);
129
+ private journal;
130
+ private factory;
131
+ private schemaReady;
132
+ private ownerTail;
133
+ constructor(factory?: IDBFactory, name?: string, storageScope?: string | undefined, migrateLegacy?: boolean, metadataOnly?: boolean);
134
+ private owned;
92
135
  private transaction;
93
136
  private key;
137
+ /** Keyset pages avoid materializing a second, unbounded array of durable rows.
138
+ * Keep the caller's transaction so every page belongs to one consistent view. */
139
+ private readPages;
140
+ private hydrate;
141
+ private loadCurrent;
142
+ private loadStored;
143
+ private cleanupClaimedLegacy;
94
144
  load(appId: string, profileId: string): Promise<ReadIndexState | undefined>;
95
- update(appId: string, profileId: string, transform: (current: ReadIndexState) => ReadIndexState): Promise<ReadIndexState>;
145
+ loadVersioned(appId: string, profileId: string): Promise<{
146
+ state: ReadIndexState | undefined;
147
+ versions: Record<string, number>;
148
+ }>;
149
+ loadVersions(appId: string, profileId: string): Promise<ReadIndexVersions>;
150
+ invalidateTeam(appId: string, profileId: string, teamId: string, version: number, knownThreadIds?: readonly string[]): Promise<ReadIndexState>;
151
+ private observe;
152
+ update(appId: string, profileId: string, transform: ReadIndexTransform, observation?: ReadObservationScope): Promise<ReadIndexState>;
153
+ private updateOwned;
154
+ private writeState;
155
+ private cleanUnreachable;
156
+ private changes;
96
157
  close(): Promise<void>;
97
158
  }
98
159
  export declare function sourcesInConversation(state: ReadIndexState, conversationId: string): IndexedReadThread[];
99
160
  /** Aggregate logical history while each original source retains its own read cursor. */
100
- export declare function unreadInConversation(state: ReadIndexState, conversationId: string): {
161
+ export declare function unreadInConversation(state: ReadIndexState, conversationId: string, hidden?: ReadonlyMap<string, ReadonlySet<string>>): {
101
162
  unreadMessageCount: number;
102
163
  unreadMentionCount: number;
103
164
  badgeCount: number;