@rebasepro/client 0.14.2-canary.gca521e9 → 0.15.0
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.es.js +14 -1
- package/dist/index.es.js.map +1 -1
- package/package.json +4 -4
- package/src/offline-query.test.ts +51 -0
- package/src/offline-query.ts +33 -1
- package/src/transport-baseurl.test.ts +2 -2
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_STORAGE_SOURCE_KEY, EntityReference, EntityRelation, GeoPoint, PUBLIC_STORAGE_PREFIX, RebaseApiError, RebaseApiError as RebaseApiError$1, RebaseClientError, RebaseClientError as RebaseClientError$1, Vector, isPublicStoragePath, toCanonicalOp } from "@rebasepro/types";
|
|
1
|
+
import { DEFAULT_STORAGE_SOURCE_KEY, EntityReference, EntityRelation, GeoPoint, PUBLIC_STORAGE_PREFIX, RebaseApiError, RebaseApiError as RebaseApiError$1, RebaseClientError, RebaseClientError as RebaseClientError$1, Vector, isPublicStoragePath, parseRelationAggregateSort, toCanonicalOp } from "@rebasepro/types";
|
|
2
2
|
import { COMPOSITE_ID_SEPARATOR, QueryBuilder, RebasePaginationError, and, buildCompositeId, collectAllPages, cond, normalizeOrderBy, or, paginateFind, resolveFindWindow, serializeFilter, serializeLogicalCondition, serializeOrderBy } from "@rebasepro/common";
|
|
3
3
|
import { toSnakeCase } from "@rebasepro/utils";
|
|
4
4
|
//#region src/reviver.ts
|
|
@@ -4214,8 +4214,20 @@ function isExactlyEvaluable(params) {
|
|
|
4214
4214
|
if (params.vectorSearch) return false;
|
|
4215
4215
|
if (whereOrders(params.where)) return false;
|
|
4216
4216
|
if (logicalOrders(params.logical)) return false;
|
|
4217
|
+
if (whereReachesThroughRelation(params.where)) return false;
|
|
4218
|
+
if (logicalReachesThroughRelation(params.logical)) return false;
|
|
4217
4219
|
return true;
|
|
4218
4220
|
}
|
|
4221
|
+
/** Does any filter key reach outside this row — `applications.status`? */
|
|
4222
|
+
function whereReachesThroughRelation(where) {
|
|
4223
|
+
return where ? Object.keys(where).some((field) => field.includes(".")) : false;
|
|
4224
|
+
}
|
|
4225
|
+
/** The same question, through an `and(...)`/`or(...)` tree. */
|
|
4226
|
+
function logicalReachesThroughRelation(condition, depth = 0) {
|
|
4227
|
+
if (!condition || depth > 32) return false;
|
|
4228
|
+
if ("type" in condition) return (condition.conditions ?? []).some((c) => logicalReachesThroughRelation(c, depth + 1));
|
|
4229
|
+
return typeof condition.column === "string" && condition.column.includes(".");
|
|
4230
|
+
}
|
|
4219
4231
|
/**
|
|
4220
4232
|
* Would sorting `rows` locally reproduce the order the server would have sent?
|
|
4221
4233
|
*
|
|
@@ -4237,6 +4249,7 @@ function isExactlyEvaluable(params) {
|
|
|
4237
4249
|
function isLocallySortable(rows, orderBy) {
|
|
4238
4250
|
const keys = normalizeOrderBy(orderBy);
|
|
4239
4251
|
if (!keys) return true;
|
|
4252
|
+
if (keys.some(([field]) => parseRelationAggregateSort(field))) return false;
|
|
4240
4253
|
return keys.every(([field]) => rows.every((row) => {
|
|
4241
4254
|
const value = toComparable(row[field]);
|
|
4242
4255
|
if (isNullish(value)) return true;
|