MCPcopy Index your code
hub / github.com/simstudioai/sim / classifyExternalDoc

Function classifyExternalDoc

apps/sim/lib/knowledge/connectors/sync-engine.ts:90–107  ·  view source on GitHub ↗
(
  extDoc: Pick<ExternalDocument, 'content' | 'contentDeferred' | 'contentHash' | 'skippedReason'>,
  existing: { id: string; contentHash: string | null } | undefined
)

Source from the content-addressed store, hash-verified

88 * - `add` / `update` / `unchanged`: normal content reconciliation by content hash.
89 */
90export function classifyExternalDoc(
91 extDoc: Pick<ExternalDocument, 'content' | 'contentDeferred' | 'contentHash' | 'skippedReason'>,
92 existing: { id: string; contentHash: string | null } | undefined
93): DocClassification {
94 if (extDoc.skippedReason) {
95 return existing ? { type: 'unchanged' } : { type: 'skip' }
96 }
97 if (!extDoc.content.trim() && !extDoc.contentDeferred) {
98 return { type: 'drop' }
99 }
100 if (!existing) {
101 return { type: 'add' }
102 }
103 if (existing.contentHash !== extDoc.contentHash) {
104 return { type: 'update', existingId: existing.id }
105 }
106 return { type: 'unchanged' }
107}
108
109/** Estimated source bytes for a pending op, taken from its listing metadata. */
110function estimateOpSizeBytes(op: DocOp): number {

Callers 2

executeSyncFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected