@antzsoft/chat-core 1.2.8 → 1.2.9

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/index.cjs CHANGED
@@ -152,7 +152,13 @@ module.exports = __toCommonJS(src_exports);
152
152
 
153
153
  // src/config/types.ts
154
154
  function resolveConfig(config) {
155
- const socketUrl = config.socketUrl ?? config.apiUrl.replace(/\/api\/v\d+\/?$/, "").replace(/\/$/, "");
155
+ const socketUrl = config.socketUrl ?? (() => {
156
+ try {
157
+ return new URL(config.apiUrl).origin;
158
+ } catch {
159
+ return config.apiUrl;
160
+ }
161
+ })();
156
162
  let socketOrigin = socketUrl;
157
163
  let socketPath = "/socket.io";
158
164
  try {
@@ -854,14 +860,22 @@ var syncApi = {
854
860
  },
855
861
  /**
856
862
  * Per-conversation delta sync — call when a conversation has `needs_refresh = true`
857
- * or on fresh install (omit `since` to receive the full message history).
863
+ * or on fresh install (omit both since and afterSeq to receive full history).
858
864
  * Covers messages, deletedForMe, full reaction state, stars, participant changes,
859
865
  * and read receipts — everything needed to make local SQLite authoritative.
866
+ *
867
+ * Prefer `afterSeq` when available (new server) — paginated, collision-safe.
868
+ * Fall back to `since` timestamp for old servers or first sync on a new install.
869
+ * When `hasMore` is true in the response, call again with the returned `nextSeq`.
860
870
  */
861
- pullConversation(conversationId, since) {
862
- return getApiClient().get(`/conversations/${conversationId}/sync`, {
863
- params: since ? { since } : {}
864
- }).then((r) => r.data);
871
+ pullConversation(conversationId, opts) {
872
+ const params = {};
873
+ if (opts?.afterSeq !== void 0) {
874
+ params.afterSeq = opts.afterSeq;
875
+ } else if (opts?.since) {
876
+ params.since = opts.since;
877
+ }
878
+ return getApiClient().get(`/conversations/${conversationId}/sync`, { params }).then((r) => r.data);
865
879
  }
866
880
  };
867
881