@opengeni/documents 0.7.0-canary.0 → 0.8.2-canary.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/documents",
3
- "version": "0.7.0-canary.0",
3
+ "version": "0.8.2-canary.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,10 +40,10 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@llamaindex/liteparse": "^1.5.3",
43
- "@opengeni/config": "^0.19.1-canary.0",
44
- "@opengeni/contracts": "^2.3.0-canary.0",
45
- "@opengeni/db": "^3.2.0-canary.0",
46
- "@opengeni/storage": "^0.2.106-canary.0",
43
+ "@opengeni/config": "^0.20.1-canary.0",
44
+ "@opengeni/contracts": "^2.5.0-canary.0",
45
+ "@opengeni/db": "^3.4.0-canary.0",
46
+ "@opengeni/storage": "^0.2.108-canary.0",
47
47
  "drizzle-orm": "^0.45.2",
48
48
  "openai": "6.47.0"
49
49
  }
package/src/index.ts CHANGED
@@ -259,6 +259,7 @@ export type DocumentSearchInput = {
259
259
  limit?: number | undefined;
260
260
  mode?: DocumentSearchMode | undefined;
261
261
  sourceKinds?: KnowledgeSourceKind[] | undefined;
262
+ authorityKinds?: DocumentAuthorityKind[] | undefined;
262
263
  aclTags?: string[] | undefined;
263
264
  access?: DocumentAccessFilter | undefined;
264
265
  };
@@ -1160,7 +1161,10 @@ export async function getDocumentDefaultCollectionBackfillAudit(
1160
1161
  operationsNextCursor: operationTail
1161
1162
  ? encodeDocumentMigrationAuditCursor(
1162
1163
  ["backfill-operations", input.accountId, input.runId],
1163
- { timestamp: operationTail.createdAt, id: operationTail.operationId },
1164
+ {
1165
+ timestamp: operationTail.createdAt,
1166
+ id: operationTail.operationId,
1167
+ },
1164
1168
  )
1165
1169
  : null,
1166
1170
  receiptsHasMore,
@@ -1283,9 +1287,14 @@ function decodeDocumentMigrationAuditCursor(
1283
1287
  ) {
1284
1288
  throw new Error("cursor payload");
1285
1289
  }
1286
- return { timestamp: typeof parsed.t === "string" ? parsed.t : null, id: parsed.i };
1290
+ return {
1291
+ timestamp: typeof parsed.t === "string" ? parsed.t : null,
1292
+ id: parsed.i,
1293
+ };
1287
1294
  } catch (error) {
1288
- throw new Error("invalid document migration audit cursor", { cause: error });
1295
+ throw new Error("invalid document migration audit cursor", {
1296
+ cause: error,
1297
+ });
1289
1298
  }
1290
1299
  }
1291
1300
 
@@ -1436,7 +1445,9 @@ function decodeDocumentAuthorityReclassificationCursor(
1436
1445
  }
1437
1446
  return { createdAt: parsed.t, operationId: parsed.i };
1438
1447
  } catch (error) {
1439
- throw new Error("invalid document authority receipt cursor", { cause: error });
1448
+ throw new Error("invalid document authority receipt cursor", {
1449
+ cause: error,
1450
+ });
1440
1451
  }
1441
1452
  }
1442
1453
 
@@ -1888,7 +1899,11 @@ export function encodeDocumentIndexCheckpoint(input: {
1888
1899
 
1889
1900
  export function decodeDocumentIndexCheckpoint(
1890
1901
  value: string,
1891
- scope: { accountId: string; workspaceId: string; initiatingSubjectId: string },
1902
+ scope: {
1903
+ accountId: string;
1904
+ workspaceId: string;
1905
+ initiatingSubjectId: string;
1906
+ },
1892
1907
  ): bigint {
1893
1908
  try {
1894
1909
  if (!value || value.length > DOCUMENT_INDEX_CHECKPOINT_MAX_CHARS) {
@@ -2262,7 +2277,11 @@ async function curateDroppedDocument(
2262
2277
  const bases = await listDocumentBases(db, document.workspaceId);
2263
2278
  const candidates: DocumentCurationCandidateBase[] = bases
2264
2279
  .filter((base) => base.id !== document.baseId)
2265
- .map((base) => ({ id: base.id, name: base.name, description: base.description }));
2280
+ .map((base) => ({
2281
+ id: base.id,
2282
+ name: base.name,
2283
+ description: base.description,
2284
+ }));
2266
2285
  const input: DocumentCurationInput = {
2267
2286
  text: parsed.text.slice(0, DOCUMENT_CURATION_MAX_INPUT_CHARS),
2268
2287
  filename: file.filename,
@@ -2454,6 +2473,7 @@ export async function searchEffectiveDocuments(
2454
2473
  limit: input.limit,
2455
2474
  mode: input.mode,
2456
2475
  sourceKinds: input.sourceKinds,
2476
+ authorityKinds: input.authorityKinds,
2457
2477
  aclTags: input.aclTags,
2458
2478
  // Construct the lower-level access filter here instead of spreading the
2459
2479
  // caller input, so an untyped/legacy access override is always ignored.
@@ -2496,6 +2516,7 @@ export async function searchEffectiveKnowledge(
2496
2516
  ...(input.baseIds ? { baseIds: input.baseIds } : {}),
2497
2517
  ...(input.mode ? { mode: input.mode } : {}),
2498
2518
  ...(input.sourceKinds ? { sourceKinds: input.sourceKinds } : {}),
2519
+ ...(input.authorityKinds ? { authorityKinds: input.authorityKinds } : {}),
2499
2520
  ...(input.aclTags ? { aclTags: input.aclTags } : {}),
2500
2521
  access,
2501
2522
  },
@@ -2539,6 +2560,9 @@ export async function searchEffectiveKnowledge(
2539
2560
  ranked.map((result) => result.chunkId),
2540
2561
  ),
2541
2562
  eq(schema.documents.status, "ready"),
2563
+ ...(input.authorityKinds?.length
2564
+ ? [inArray(schema.documents.authorityKind, input.authorityKinds)]
2565
+ : []),
2542
2566
  ...documentAccessConditions(input.workspaceId, access),
2543
2567
  ),
2544
2568
  ),
@@ -3074,7 +3098,10 @@ export async function browseEffectiveKnowledge(
3074
3098
  async (scopedDb) => {
3075
3099
  if (parent) {
3076
3100
  const [authorizedParent] = await scopedDb
3077
- .select({ id: schema.documents.id, indexSequence: schema.documents.indexSequence })
3101
+ .select({
3102
+ id: schema.documents.id,
3103
+ indexSequence: schema.documents.indexSequence,
3104
+ })
3078
3105
  .from(schema.documents)
3079
3106
  .where(
3080
3107
  and(
@@ -3086,7 +3113,10 @@ export async function browseEffectiveKnowledge(
3086
3113
  )
3087
3114
  .limit(1);
3088
3115
  if (!authorizedParent) {
3089
- return selectKnowledgeBrowseRecords({ entries: [], hasMoreAfterEntries: false });
3116
+ return selectKnowledgeBrowseRecords({
3117
+ entries: [],
3118
+ hasMoreAfterEntries: false,
3119
+ });
3090
3120
  }
3091
3121
  if (authorizedParent.indexSequence === null) {
3092
3122
  throw new Error("ready knowledge document is missing its index revision");
@@ -3203,7 +3233,11 @@ export function encodeKnowledgeBrowseCursor(
3203
3233
  if (position < 0n) throw new Error("knowledge browse cursor position is invalid");
3204
3234
  const version = knowledgeBrowseCursorVersion(scope);
3205
3235
  return Buffer.from(
3206
- JSON.stringify({ v: version, s: knowledgeBrowseCursorScope(scope), q: position.toString() }),
3236
+ JSON.stringify({
3237
+ v: version,
3238
+ s: knowledgeBrowseCursorScope(scope),
3239
+ q: position.toString(),
3240
+ }),
3207
3241
  "utf8",
3208
3242
  ).toString("base64url");
3209
3243
  }
@@ -3283,7 +3317,10 @@ function parseKnowledgeRecordId(value: string): {
3283
3317
  value,
3284
3318
  );
3285
3319
  if (!match) throw new Error("invalid knowledge record id");
3286
- return { kind: match[1] as "document" | "document_chunk", id: match[2]!.toLowerCase() };
3320
+ return {
3321
+ kind: match[1] as "document" | "document_chunk",
3322
+ id: match[2]!.toLowerCase(),
3323
+ };
3287
3324
  }
3288
3325
 
3289
3326
  function knowledgeDocumentRecord(
@@ -3887,6 +3924,9 @@ function documentSearchConditions(input: DocumentSearchInput, embeddingModel?: s
3887
3924
  if (input.sourceKinds?.length) {
3888
3925
  conditions.push(inArray(schema.documents.sourceKind, input.sourceKinds));
3889
3926
  }
3927
+ if (input.authorityKinds?.length) {
3928
+ conditions.push(inArray(schema.documents.authorityKind, input.authorityKinds));
3929
+ }
3890
3930
  const aclTags = cleanStringArray(input.aclTags);
3891
3931
  if (aclTags.length > 0) {
3892
3932
  conditions.push(sql`${schema.documents.aclTags} @> ${JSON.stringify(aclTags)}::jsonb`);