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

Function toAdf

apps/sim/tools/jira/utils.ts:13–52  ·  view source on GitHub ↗
(value: string | Record<string, unknown>)

Source from the content-addressed store, hash-verified

11 * it is returned as-is. If it is a plain string, it is wrapped in a single-paragraph ADF doc.
12 */
13export function toAdf(value: string | Record<string, unknown>): Record<string, unknown> {
14 if (typeof value === 'object') {
15 if (value.type === 'doc') {
16 return value
17 }
18 if (value.type && Array.isArray(value.content)) {
19 return { type: 'doc', version: 1, content: [value] }
20 }
21 }
22 if (typeof value === 'string') {
23 try {
24 const parsed = JSON.parse(value)
25 if (typeof parsed === 'object' && parsed !== null && parsed.type === 'doc') {
26 return parsed
27 }
28 if (
29 typeof parsed === 'object' &&
30 parsed !== null &&
31 parsed.type &&
32 Array.isArray(parsed.content)
33 ) {
34 return { type: 'doc', version: 1, content: [parsed] }
35 }
36 } catch {
37 // Not JSON — treat as plain text below
38 }
39 }
40 return {
41 type: 'doc',
42 version: 1,
43 content: [
44 {
45 type: 'paragraph',
46 content: [
47 { type: 'text', text: typeof value === 'string' ? value : JSON.stringify(value) },
48 ],
49 },
50 ],
51 }
52}
53
54/**
55 * Extracts plain text from Atlassian Document Format (ADF) content.

Callers 8

add_comment.tsFile · 0.90
buildTransitionBodyFunction · 0.90
update_comment.tsFile · 0.90
buildWorklogBodyFunction · 0.90
buildWorklogBodyFunction · 0.90
route.tsFile · 0.90
route.tsFile · 0.90

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected