@powerhousedao/reactor 6.0.0-dev.216 → 6.0.0-dev.217
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.js +15 -11
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1691,17 +1691,21 @@ var KyselyOperationIndex = class KyselyOperationIndex {
|
|
|
1691
1691
|
}
|
|
1692
1692
|
async find(collectionId, cursor, view, paging, signal) {
|
|
1693
1693
|
if (signal?.aborted) throw new Error("Operation aborted");
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1694
|
+
const outerCursor = cursor ?? -1;
|
|
1695
|
+
const pagingCursorOrdinal = paging?.cursor !== void 0 ? Number.parseInt(paging.cursor, 10) : -1;
|
|
1696
|
+
const buildBranch = (kind) => {
|
|
1697
|
+
let qb = this.queryExecutor.selectFrom("operation_index_operations as oi").innerJoin("document_collections as dc", "oi.documentId", "dc.documentId").selectAll("oi").select(["dc.documentId", "dc.collectionId"]).where("dc.collectionId", "=", collectionId).where(sql`(dc."leftOrdinal" IS NULL OR oi.ordinal < dc."leftOrdinal")`);
|
|
1698
|
+
if (kind === "joiner") qb = qb.where("dc.joinedOrdinal", ">", BigInt(outerCursor)).where("oi.ordinal", "<=", outerCursor);
|
|
1699
|
+
else qb = qb.where("oi.ordinal", ">", outerCursor);
|
|
1700
|
+
qb = qb.where("oi.ordinal", ">", pagingCursorOrdinal);
|
|
1701
|
+
if (view?.branch) qb = qb.where("oi.branch", "=", view.branch);
|
|
1702
|
+
if (view?.scopes && view.scopes.length > 0) qb = qb.where("oi.scope", "in", view.scopes);
|
|
1703
|
+
if (view?.excludeSourceRemote) qb = qb.where("oi.sourceRemote", "!=", view.excludeSourceRemote);
|
|
1704
|
+
return qb;
|
|
1705
|
+
};
|
|
1706
|
+
let unionQuery = buildBranch("joiner").unionAll(buildBranch("newOps")).orderBy("ordinal", "asc");
|
|
1707
|
+
if (paging?.limit) unionQuery = unionQuery.limit(paging.limit + 1);
|
|
1708
|
+
const rows = await unionQuery.execute();
|
|
1705
1709
|
let hasMore = false;
|
|
1706
1710
|
let items = rows;
|
|
1707
1711
|
if (paging?.limit && rows.length > paging.limit) {
|