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

Function pageToStub

apps/sim/connectors/confluence/confluence.ts:98–127  ·  view source on GitHub ↗

* Produces a canonical metadata stub with a deterministic contentHash that * does not depend on which API surface (v1 CQL or v2) returned the page.

(
  page: Record<string, unknown>,
  options: {
    spaceId?: unknown
    labels?: string[]
    sourceUrl?: string
  } = {}
)

Source from the content-addressed store, hash-verified

96 * does not depend on which API surface (v1 CQL or v2) returned the page.
97 */
98function pageToStub(
99 page: Record<string, unknown>,
100 options: {
101 spaceId?: unknown
102 labels?: string[]
103 sourceUrl?: string
104 } = {}
105): ExternalDocument {
106 const version = page.version as Record<string, unknown> | undefined
107 const versionNumber = version?.number as number | undefined
108 const lastModified = (version?.createdAt ?? version?.when ?? '') as string
109 const versionKey = versionNumber ?? lastModified
110
111 return {
112 externalId: String(page.id),
113 title: (page.title as string) || 'Untitled',
114 content: '',
115 contentDeferred: true,
116 mimeType: 'text/plain',
117 sourceUrl: options.sourceUrl,
118 contentHash: `confluence:${page.id}:${versionKey}`,
119 metadata: {
120 spaceId: options.spaceId,
121 status: page.status,
122 version: versionNumber,
123 labels: options.labels ?? [],
124 lastModified,
125 },
126 }
127}
128
129/**
130 * Converts a v1 CQL search result item to a lightweight metadata stub.

Callers 3

cqlResultToStubFunction · 0.70
confluence.tsFile · 0.70
listDocumentsV2Function · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected