@rebasepro/client 0.9.1-canary.a57c262 → 0.9.1-canary.ad25bc0
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/collection.test.d.ts +1 -0
- package/dist/cron.test.d.ts +1 -0
- package/dist/data-proxy.test.d.ts +1 -0
- package/dist/index.es.js +9 -35
- package/dist/index.es.js.map +1 -1
- package/dist/realtime-optout.test.d.ts +1 -0
- package/dist/transport.d.ts +0 -21
- package/dist/websocket.d.ts +0 -13
- package/package.json +4 -4
- package/src/transport.ts +0 -21
- package/src/websocket.ts +11 -62
- package/src/realtime-row-identity.test.ts +0 -254
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_STORAGE_SOURCE_KEY, EntityReference, EntityRelation, GeoPoint, PUBLIC_STORAGE_PREFIX, RebaseApiError, RebaseApiError as RebaseApiError$1, RebaseClientError, Vector, isPublicStoragePath } from "@rebasepro/types";
|
|
2
|
-
import {
|
|
2
|
+
import { QueryBuilder, and, cond, or, serializeFilter, serializeLogicalCondition, serializeOrderBy } from "@rebasepro/common";
|
|
3
3
|
import { toSnakeCase } from "@rebasepro/utils";
|
|
4
4
|
//#region src/reviver.ts
|
|
5
5
|
function rebaseReviver(_key, value) {
|
|
@@ -1696,9 +1696,7 @@ var RebaseWebSocketClient = class {
|
|
|
1696
1696
|
const collectionSub = this.collectionSubscriptions.get(subscriptionKey);
|
|
1697
1697
|
if (collectionSub) {
|
|
1698
1698
|
const incomingRows = message.rows || [];
|
|
1699
|
-
const
|
|
1700
|
-
if (updatePks) collectionSub.pks = updatePks;
|
|
1701
|
-
const rows = this.mergeRows(collectionSub.latestData, incomingRows, collectionSub.pks);
|
|
1699
|
+
const rows = this.mergeRows(collectionSub.latestData, incomingRows);
|
|
1702
1700
|
collectionSub.latestData = rows;
|
|
1703
1701
|
collectionSub.lastUpdated = Date.now();
|
|
1704
1702
|
collectionSub.isInitialDataReceived = true;
|
|
@@ -1720,14 +1718,12 @@ var RebaseWebSocketClient = class {
|
|
|
1720
1718
|
const collectionSub = this.collectionSubscriptions.get(subscriptionKey);
|
|
1721
1719
|
if (collectionSub && collectionSub.isInitialDataReceived && collectionSub.latestData) {
|
|
1722
1720
|
const patchWireEntity = message.row ?? null;
|
|
1723
|
-
const
|
|
1724
|
-
const patchEntityId = patchMessage.id;
|
|
1725
|
-
if (patchMessage.pks) collectionSub.pks = patchMessage.pks;
|
|
1721
|
+
const patchEntityId = message.id;
|
|
1726
1722
|
const patchRow = patchWireEntity ? patchWireEntity : null;
|
|
1727
1723
|
let updated;
|
|
1728
|
-
if (patchRow === null) updated = collectionSub.latestData.filter((e) =>
|
|
1724
|
+
if (patchRow === null) updated = collectionSub.latestData.filter((e) => String(e.id) !== String(patchEntityId));
|
|
1729
1725
|
else {
|
|
1730
|
-
const idx = collectionSub.latestData.findIndex((e) =>
|
|
1726
|
+
const idx = collectionSub.latestData.findIndex((e) => String(e.id) === String(patchRow.id));
|
|
1731
1727
|
if (idx >= 0) {
|
|
1732
1728
|
updated = [...collectionSub.latestData];
|
|
1733
1729
|
updated[idx] = patchRow;
|
|
@@ -2077,39 +2073,17 @@ var RebaseWebSocketClient = class {
|
|
|
2077
2073
|
return val;
|
|
2078
2074
|
}
|
|
2079
2075
|
/**
|
|
2080
|
-
* The address of a row, for matching it against another copy of itself.
|
|
2081
|
-
*
|
|
2082
|
-
* A row is exactly its columns and carries no address, so it is derived
|
|
2083
|
-
* from the key columns the server named — including the ordinary case where
|
|
2084
|
-
* that key is `id`, which the server reports like any other.
|
|
2085
|
-
*
|
|
2086
|
-
* Undefined when there are no keys, which means the server could not
|
|
2087
|
-
* resolve any: such rows genuinely cannot be recognised, and guessing at a
|
|
2088
|
-
* column called `id` would be inventing an identity for a table that has
|
|
2089
|
-
* none.
|
|
2090
|
-
*/
|
|
2091
|
-
rowAddress(row, pks) {
|
|
2092
|
-
if (!pks || pks.length === 0) return void 0;
|
|
2093
|
-
const address = buildCompositeId(row, pks);
|
|
2094
|
-
if (!address || address.split(COMPOSITE_ID_SEPARATOR).every((part) => part === "")) return void 0;
|
|
2095
|
-
return address;
|
|
2096
|
-
}
|
|
2097
|
-
/**
|
|
2098
2076
|
* Merge incoming rows with cached data, preserving cached references
|
|
2099
2077
|
* for rows whose values haven't changed. This avoids unnecessary
|
|
2100
2078
|
* React re-renders when the server refetches all rows but most
|
|
2101
2079
|
* haven't actually changed.
|
|
2102
2080
|
*/
|
|
2103
|
-
mergeRows(cached, incoming
|
|
2081
|
+
mergeRows(cached, incoming) {
|
|
2104
2082
|
if (!cached || cached.length === 0) return incoming;
|
|
2105
2083
|
const cachedById = /* @__PURE__ */ new Map();
|
|
2106
|
-
for (const row of cached)
|
|
2107
|
-
const address = this.rowAddress(row, pks);
|
|
2108
|
-
if (address !== void 0) cachedById.set(address, row);
|
|
2109
|
-
}
|
|
2084
|
+
for (const row of cached) cachedById.set(row.id, row);
|
|
2110
2085
|
return incoming.map((incomingRow) => {
|
|
2111
|
-
const
|
|
2112
|
-
const cachedRow = address === void 0 ? void 0 : cachedById.get(address);
|
|
2086
|
+
const cachedRow = cachedById.get(incomingRow.id);
|
|
2113
2087
|
if (!cachedRow) return incomingRow;
|
|
2114
2088
|
const normCached = this.normalizeForComparison(cachedRow);
|
|
2115
2089
|
const normIncoming = this.normalizeForComparison(incomingRow);
|
|
@@ -2121,7 +2095,7 @@ var RebaseWebSocketClient = class {
|
|
|
2121
2095
|
cached: normCached[key],
|
|
2122
2096
|
incoming: normIncoming[key]
|
|
2123
2097
|
};
|
|
2124
|
-
console.debug(`[RebaseWS] Row ${
|
|
2098
|
+
console.debug(`[RebaseWS] Row ${incomingRow.id} refetch mismatch:\n`, JSON.stringify(mismatches, null, 2));
|
|
2125
2099
|
}
|
|
2126
2100
|
return incomingRow;
|
|
2127
2101
|
});
|