@kubun/store-graph 0.14.0 → 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/lib/api.js CHANGED
@@ -989,12 +989,16 @@ export function createGraphStore(db, adapter) {
989
989
  throw new SearchNotEnabledError(modelID);
990
990
  }
991
991
  }
992
+ const offset = params.offset ?? 0;
993
+ // Fetch enough from each model to cover the full [0, offset+first) window
994
+ // before the cross-model merge; the final slice trims to the page.
995
+ const perModelLimit = params.first != null ? offset + params.first : undefined;
992
996
  const allResults = [];
993
997
  for (const modelID of params.modelIDs){
994
998
  const hits = await adapter.searchIndex(db, {
995
999
  query: params.query,
996
1000
  modelID,
997
- limit: params.first ?? 50
1001
+ limit: perModelLimit ?? 50
998
1002
  });
999
1003
  for (const hit of hits){
1000
1004
  allResults.push({
@@ -1005,9 +1009,9 @@ export function createGraphStore(db, adapter) {
1005
1009
  }
1006
1010
  }
1007
1011
  // Sort by absolute rank descending (SQLite bm25 returns negative, PG ts_rank positive)
1008
- allResults.sort((a, b)=>Math.abs(b.rank) - Math.abs(a.rank));
1009
- if (params.first) {
1010
- return allResults.slice(0, params.first);
1012
+ allResults.sort((a, b)=>Math.abs(b.rank) - Math.abs(a.rank) || a.documentID.localeCompare(b.documentID));
1013
+ if (params.first != null) {
1014
+ return allResults.slice(offset, offset + params.first);
1011
1015
  }
1012
1016
  return allResults;
1013
1017
  },
package/lib/tables.d.ts CHANGED
@@ -237,7 +237,7 @@ export type SearchDocumentsParams = {
237
237
  query: string;
238
238
  modelIDs: Array<string>;
239
239
  first?: number;
240
- after?: string;
240
+ offset?: number;
241
241
  };
242
242
  export type SearchDocumentResult = {
243
243
  documentID: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubun/store-graph",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "keywords": [],
5
5
  "license": "see LICENSE.md",
6
6
  "sideEffects": false,
@@ -15,16 +15,16 @@
15
15
  "LICENSE.md"
16
16
  ],
17
17
  "dependencies": {
18
- "@kubun/db": "^0.14.0",
19
- "@kubun/db-adapter": "^0.14.0",
20
- "@kubun/id": "^0.14.0",
21
- "@kubun/protocol": "^0.14.0",
18
+ "@kubun/db": "^0.15.0",
19
+ "@kubun/db-adapter": "^0.15.0",
20
+ "@kubun/id": "^0.15.0",
21
+ "@kubun/protocol": "^0.15.0",
22
22
  "@sozai/codec": "^0.4.0",
23
23
  "kysely": "^0.29.5"
24
24
  },
25
25
  "devDependencies": {
26
- "@kubun/db-better-sqlite": "^0.14.0",
27
- "@kubun/db-postgres": "^0.14.0",
26
+ "@kubun/db-better-sqlite": "^0.15.0",
27
+ "@kubun/db-postgres": "^0.15.0",
28
28
  "@testcontainers/postgresql": "^12.1.0"
29
29
  },
30
30
  "publishConfig": {