@knpkv/confluence-to-markdown 0.2.0 → 0.4.1

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.
Files changed (336) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/LICENSE +21 -0
  3. package/README.md +282 -14
  4. package/dist/ConfluenceAuth.d.ts +76 -0
  5. package/dist/ConfluenceAuth.d.ts.map +1 -0
  6. package/dist/ConfluenceAuth.js +356 -0
  7. package/dist/ConfluenceAuth.js.map +1 -0
  8. package/dist/ConfluenceClient.d.ts +26 -2
  9. package/dist/ConfluenceClient.d.ts.map +1 -1
  10. package/dist/ConfluenceClient.js +98 -92
  11. package/dist/ConfluenceClient.js.map +1 -1
  12. package/dist/ConfluenceConfig.d.ts +4 -24
  13. package/dist/ConfluenceConfig.d.ts.map +1 -1
  14. package/dist/ConfluenceConfig.js +45 -7
  15. package/dist/ConfluenceConfig.js.map +1 -1
  16. package/dist/ConfluenceError.d.ts +89 -6
  17. package/dist/ConfluenceError.d.ts.map +1 -1
  18. package/dist/ConfluenceError.js +88 -5
  19. package/dist/ConfluenceError.js.map +1 -1
  20. package/dist/GitError.d.ts +103 -0
  21. package/dist/GitError.d.ts.map +1 -0
  22. package/dist/GitError.js +85 -0
  23. package/dist/GitError.js.map +1 -0
  24. package/dist/GitService.d.ts +175 -0
  25. package/dist/GitService.d.ts.map +1 -0
  26. package/dist/GitService.js +431 -0
  27. package/dist/GitService.js.map +1 -0
  28. package/dist/LocalFileSystem.d.ts +29 -4
  29. package/dist/LocalFileSystem.d.ts.map +1 -1
  30. package/dist/LocalFileSystem.js +80 -6
  31. package/dist/LocalFileSystem.js.map +1 -1
  32. package/dist/MarkdownConverter.d.ts +49 -2
  33. package/dist/MarkdownConverter.d.ts.map +1 -1
  34. package/dist/MarkdownConverter.js +73 -111
  35. package/dist/MarkdownConverter.js.map +1 -1
  36. package/dist/SchemaConverterError.d.ts +108 -0
  37. package/dist/SchemaConverterError.d.ts.map +1 -0
  38. package/dist/SchemaConverterError.js +84 -0
  39. package/dist/SchemaConverterError.js.map +1 -0
  40. package/dist/Schemas.d.ts +225 -1
  41. package/dist/Schemas.d.ts.map +1 -1
  42. package/dist/Schemas.js +155 -6
  43. package/dist/Schemas.js.map +1 -1
  44. package/dist/SyncEngine.d.ts +30 -20
  45. package/dist/SyncEngine.d.ts.map +1 -1
  46. package/dist/SyncEngine.js +566 -117
  47. package/dist/SyncEngine.js.map +1 -1
  48. package/dist/ast/BlockNode.d.ts +468 -0
  49. package/dist/ast/BlockNode.d.ts.map +1 -0
  50. package/dist/ast/BlockNode.js +319 -0
  51. package/dist/ast/BlockNode.js.map +1 -0
  52. package/dist/ast/Document.d.ts +244 -0
  53. package/dist/ast/Document.d.ts.map +1 -0
  54. package/dist/ast/Document.js +69 -0
  55. package/dist/ast/Document.js.map +1 -0
  56. package/dist/ast/InlineNode.d.ts +477 -0
  57. package/dist/ast/InlineNode.d.ts.map +1 -0
  58. package/dist/ast/InlineNode.js +263 -0
  59. package/dist/ast/InlineNode.js.map +1 -0
  60. package/dist/ast/MacroNode.d.ts +267 -0
  61. package/dist/ast/MacroNode.d.ts.map +1 -0
  62. package/dist/ast/MacroNode.js +164 -0
  63. package/dist/ast/MacroNode.js.map +1 -0
  64. package/dist/ast/index.d.ts +10 -0
  65. package/dist/ast/index.d.ts.map +1 -0
  66. package/dist/ast/index.js +14 -0
  67. package/dist/ast/index.js.map +1 -0
  68. package/dist/bin.js +33 -149
  69. package/dist/bin.js.map +1 -1
  70. package/dist/commands/auth.d.ts +15 -0
  71. package/dist/commands/auth.d.ts.map +1 -0
  72. package/dist/commands/auth.js +86 -0
  73. package/dist/commands/auth.js.map +1 -0
  74. package/dist/commands/clone.d.ts +12 -0
  75. package/dist/commands/clone.d.ts.map +1 -0
  76. package/dist/commands/clone.js +93 -0
  77. package/dist/commands/clone.js.map +1 -0
  78. package/dist/commands/delete.d.ts +13 -0
  79. package/dist/commands/delete.d.ts.map +1 -0
  80. package/dist/commands/delete.js +48 -0
  81. package/dist/commands/delete.js.map +1 -0
  82. package/dist/commands/errorHandler.d.ts +14 -0
  83. package/dist/commands/errorHandler.d.ts.map +1 -0
  84. package/dist/commands/errorHandler.js +33 -0
  85. package/dist/commands/errorHandler.js.map +1 -0
  86. package/dist/commands/git.d.ts +22 -0
  87. package/dist/commands/git.d.ts.map +1 -0
  88. package/dist/commands/git.js +72 -0
  89. package/dist/commands/git.js.map +1 -0
  90. package/dist/commands/index.d.ts +11 -0
  91. package/dist/commands/index.d.ts.map +1 -0
  92. package/dist/commands/index.js +11 -0
  93. package/dist/commands/index.js.map +1 -0
  94. package/dist/commands/layers.d.ts +31 -0
  95. package/dist/commands/layers.d.ts.map +1 -0
  96. package/dist/commands/layers.js +137 -0
  97. package/dist/commands/layers.js.map +1 -0
  98. package/dist/commands/new.d.ts +9 -0
  99. package/dist/commands/new.d.ts.map +1 -0
  100. package/dist/commands/new.js +80 -0
  101. package/dist/commands/new.js.map +1 -0
  102. package/dist/commands/pageTree.d.ts +18 -0
  103. package/dist/commands/pageTree.d.ts.map +1 -0
  104. package/dist/commands/pageTree.js +20 -0
  105. package/dist/commands/pageTree.js.map +1 -0
  106. package/dist/commands/shared.d.ts +15 -0
  107. package/dist/commands/shared.d.ts.map +1 -0
  108. package/dist/commands/shared.js +27 -0
  109. package/dist/commands/shared.js.map +1 -0
  110. package/dist/commands/sync.d.ts +15 -0
  111. package/dist/commands/sync.d.ts.map +1 -0
  112. package/dist/commands/sync.js +101 -0
  113. package/dist/commands/sync.js.map +1 -0
  114. package/dist/index.d.ts +10 -1
  115. package/dist/index.d.ts.map +1 -1
  116. package/dist/index.js +14 -0
  117. package/dist/index.js.map +1 -1
  118. package/dist/internal/NodeLayers.d.ts +7 -0
  119. package/dist/internal/NodeLayers.d.ts.map +1 -0
  120. package/dist/internal/NodeLayers.js +19 -0
  121. package/dist/internal/NodeLayers.js.map +1 -0
  122. package/dist/internal/frontmatter.d.ts +10 -0
  123. package/dist/internal/frontmatter.d.ts.map +1 -1
  124. package/dist/internal/frontmatter.js +16 -0
  125. package/dist/internal/frontmatter.js.map +1 -1
  126. package/dist/internal/gitCommands.d.ts +78 -0
  127. package/dist/internal/gitCommands.d.ts.map +1 -0
  128. package/dist/internal/gitCommands.js +156 -0
  129. package/dist/internal/gitCommands.js.map +1 -0
  130. package/dist/internal/hashUtils.d.ts +42 -1
  131. package/dist/internal/hashUtils.d.ts.map +1 -1
  132. package/dist/internal/hashUtils.js +38 -2
  133. package/dist/internal/hashUtils.js.map +1 -1
  134. package/dist/internal/oauthServer.d.ts +55 -0
  135. package/dist/internal/oauthServer.d.ts.map +1 -0
  136. package/dist/internal/oauthServer.js +110 -0
  137. package/dist/internal/oauthServer.js.map +1 -0
  138. package/dist/internal/pathUtils.d.ts +21 -4
  139. package/dist/internal/pathUtils.d.ts.map +1 -1
  140. package/dist/internal/pathUtils.js +24 -13
  141. package/dist/internal/pathUtils.js.map +1 -1
  142. package/dist/internal/tokenStorage.d.ts +75 -0
  143. package/dist/internal/tokenStorage.d.ts.map +1 -0
  144. package/dist/internal/tokenStorage.js +149 -0
  145. package/dist/internal/tokenStorage.js.map +1 -0
  146. package/dist/internal/userCache.d.ts +42 -0
  147. package/dist/internal/userCache.d.ts.map +1 -0
  148. package/dist/internal/userCache.js +51 -0
  149. package/dist/internal/userCache.js.map +1 -0
  150. package/dist/parsers/ConfluenceParser.d.ts +26 -0
  151. package/dist/parsers/ConfluenceParser.d.ts.map +1 -0
  152. package/dist/parsers/ConfluenceParser.js +792 -0
  153. package/dist/parsers/ConfluenceParser.js.map +1 -0
  154. package/dist/parsers/MarkdownParser.d.ts +26 -0
  155. package/dist/parsers/MarkdownParser.d.ts.map +1 -0
  156. package/dist/parsers/MarkdownParser.js +873 -0
  157. package/dist/parsers/MarkdownParser.js.map +1 -0
  158. package/dist/parsers/index.d.ts +8 -0
  159. package/dist/parsers/index.d.ts.map +1 -0
  160. package/dist/parsers/index.js +8 -0
  161. package/dist/parsers/index.js.map +1 -0
  162. package/dist/schemas/ConfluenceSchema.d.ts +21 -0
  163. package/dist/schemas/ConfluenceSchema.d.ts.map +1 -0
  164. package/dist/schemas/ConfluenceSchema.js +38 -0
  165. package/dist/schemas/ConfluenceSchema.js.map +1 -0
  166. package/dist/schemas/ConversionSchema.d.ts +35 -0
  167. package/dist/schemas/ConversionSchema.d.ts.map +1 -0
  168. package/dist/schemas/ConversionSchema.js +208 -0
  169. package/dist/schemas/ConversionSchema.js.map +1 -0
  170. package/dist/schemas/MarkdownSchema.d.ts +21 -0
  171. package/dist/schemas/MarkdownSchema.d.ts.map +1 -0
  172. package/dist/schemas/MarkdownSchema.js +38 -0
  173. package/dist/schemas/MarkdownSchema.js.map +1 -0
  174. package/dist/schemas/hast/HastFromHtml.d.ts +27 -0
  175. package/dist/schemas/hast/HastFromHtml.d.ts.map +1 -0
  176. package/dist/schemas/hast/HastFromHtml.js +107 -0
  177. package/dist/schemas/hast/HastFromHtml.js.map +1 -0
  178. package/dist/schemas/hast/HastSchema.d.ts +195 -0
  179. package/dist/schemas/hast/HastSchema.d.ts.map +1 -0
  180. package/dist/schemas/hast/HastSchema.js +183 -0
  181. package/dist/schemas/hast/HastSchema.js.map +1 -0
  182. package/dist/schemas/hast/index.d.ts +9 -0
  183. package/dist/schemas/hast/index.d.ts.map +1 -0
  184. package/dist/schemas/hast/index.js +3 -0
  185. package/dist/schemas/hast/index.js.map +1 -0
  186. package/dist/schemas/index.d.ts +14 -0
  187. package/dist/schemas/index.d.ts.map +1 -0
  188. package/dist/schemas/index.js +16 -0
  189. package/dist/schemas/index.js.map +1 -0
  190. package/dist/schemas/mdast/MdastFromMarkdown.d.ts +30 -0
  191. package/dist/schemas/mdast/MdastFromMarkdown.d.ts.map +1 -0
  192. package/dist/schemas/mdast/MdastFromMarkdown.js +79 -0
  193. package/dist/schemas/mdast/MdastFromMarkdown.js.map +1 -0
  194. package/dist/schemas/mdast/MdastSchema.d.ts +385 -0
  195. package/dist/schemas/mdast/MdastSchema.d.ts.map +1 -0
  196. package/dist/schemas/mdast/MdastSchema.js +266 -0
  197. package/dist/schemas/mdast/MdastSchema.js.map +1 -0
  198. package/dist/schemas/mdast/index.d.ts +10 -0
  199. package/dist/schemas/mdast/index.d.ts.map +1 -0
  200. package/dist/schemas/mdast/index.js +4 -0
  201. package/dist/schemas/mdast/index.js.map +1 -0
  202. package/dist/schemas/mdast/mdastToString.d.ts +13 -0
  203. package/dist/schemas/mdast/mdastToString.d.ts.map +1 -0
  204. package/dist/schemas/mdast/mdastToString.js +85 -0
  205. package/dist/schemas/mdast/mdastToString.js.map +1 -0
  206. package/dist/schemas/nodes/block/BlockSchema.d.ts +43 -0
  207. package/dist/schemas/nodes/block/BlockSchema.d.ts.map +1 -0
  208. package/dist/schemas/nodes/block/BlockSchema.js +634 -0
  209. package/dist/schemas/nodes/block/BlockSchema.js.map +1 -0
  210. package/dist/schemas/nodes/block/index.d.ts +7 -0
  211. package/dist/schemas/nodes/block/index.d.ts.map +1 -0
  212. package/dist/schemas/nodes/block/index.js +7 -0
  213. package/dist/schemas/nodes/block/index.js.map +1 -0
  214. package/dist/schemas/nodes/index.d.ts +9 -0
  215. package/dist/schemas/nodes/index.d.ts.map +1 -0
  216. package/dist/schemas/nodes/index.js +12 -0
  217. package/dist/schemas/nodes/index.js.map +1 -0
  218. package/dist/schemas/nodes/inline/InlineSchema.d.ts +48 -0
  219. package/dist/schemas/nodes/inline/InlineSchema.d.ts.map +1 -0
  220. package/dist/schemas/nodes/inline/InlineSchema.js +436 -0
  221. package/dist/schemas/nodes/inline/InlineSchema.js.map +1 -0
  222. package/dist/schemas/nodes/inline/index.d.ts +7 -0
  223. package/dist/schemas/nodes/inline/index.d.ts.map +1 -0
  224. package/dist/schemas/nodes/inline/index.js +7 -0
  225. package/dist/schemas/nodes/inline/index.js.map +1 -0
  226. package/dist/schemas/nodes/macro/MacroSchema.d.ts +27 -0
  227. package/dist/schemas/nodes/macro/MacroSchema.d.ts.map +1 -0
  228. package/dist/schemas/nodes/macro/MacroSchema.js +162 -0
  229. package/dist/schemas/nodes/macro/MacroSchema.js.map +1 -0
  230. package/dist/schemas/nodes/macro/index.d.ts +7 -0
  231. package/dist/schemas/nodes/macro/index.d.ts.map +1 -0
  232. package/dist/schemas/nodes/macro/index.js +7 -0
  233. package/dist/schemas/nodes/macro/index.js.map +1 -0
  234. package/dist/schemas/preprocessing/ConfluencePreprocessor.d.ts +24 -0
  235. package/dist/schemas/preprocessing/ConfluencePreprocessor.d.ts.map +1 -0
  236. package/dist/schemas/preprocessing/ConfluencePreprocessor.js +351 -0
  237. package/dist/schemas/preprocessing/ConfluencePreprocessor.js.map +1 -0
  238. package/dist/schemas/preprocessing/index.d.ts +8 -0
  239. package/dist/schemas/preprocessing/index.d.ts.map +1 -0
  240. package/dist/schemas/preprocessing/index.js +2 -0
  241. package/dist/schemas/preprocessing/index.js.map +1 -0
  242. package/dist/serializers/ConfluenceSerializer.d.ts +30 -0
  243. package/dist/serializers/ConfluenceSerializer.d.ts.map +1 -0
  244. package/dist/serializers/ConfluenceSerializer.js +551 -0
  245. package/dist/serializers/ConfluenceSerializer.js.map +1 -0
  246. package/dist/serializers/MarkdownSerializer.d.ts +34 -0
  247. package/dist/serializers/MarkdownSerializer.d.ts.map +1 -0
  248. package/dist/serializers/MarkdownSerializer.js +355 -0
  249. package/dist/serializers/MarkdownSerializer.js.map +1 -0
  250. package/dist/serializers/index.d.ts +8 -0
  251. package/dist/serializers/index.d.ts.map +1 -0
  252. package/dist/serializers/index.js +8 -0
  253. package/dist/serializers/index.js.map +1 -0
  254. package/package.json +27 -16
  255. package/src/ConfluenceAuth.ts +571 -0
  256. package/src/ConfluenceClient.ts +188 -156
  257. package/src/ConfluenceConfig.ts +63 -7
  258. package/src/ConfluenceError.ts +110 -14
  259. package/src/GitError.ts +92 -0
  260. package/src/GitService.ts +859 -0
  261. package/src/LocalFileSystem.ts +179 -9
  262. package/src/MarkdownConverter.ts +126 -122
  263. package/src/SchemaConverterError.ts +108 -0
  264. package/src/Schemas.ts +223 -6
  265. package/src/SyncEngine.ts +745 -162
  266. package/src/ast/BlockNode.ts +425 -0
  267. package/src/ast/Document.ts +90 -0
  268. package/src/ast/InlineNode.ts +323 -0
  269. package/src/ast/MacroNode.ts +245 -0
  270. package/src/ast/index.ts +83 -0
  271. package/src/bin.ts +50 -249
  272. package/src/commands/auth.ts +117 -0
  273. package/src/commands/clone.ts +145 -0
  274. package/src/commands/delete.ts +57 -0
  275. package/src/commands/errorHandler.ts +32 -0
  276. package/src/commands/git.ts +114 -0
  277. package/src/commands/index.ts +10 -0
  278. package/src/commands/layers.ts +211 -0
  279. package/src/commands/new.ts +99 -0
  280. package/src/commands/pageTree.ts +40 -0
  281. package/src/commands/shared.ts +35 -0
  282. package/src/commands/sync.ts +129 -0
  283. package/src/index.ts +21 -1
  284. package/src/internal/NodeLayers.ts +21 -0
  285. package/src/internal/frontmatter.ts +21 -0
  286. package/src/internal/gitCommands.ts +229 -0
  287. package/src/internal/hashUtils.ts +65 -3
  288. package/src/internal/oauthServer.ts +199 -0
  289. package/src/internal/pathUtils.ts +34 -17
  290. package/src/internal/tokenStorage.ts +240 -0
  291. package/src/internal/userCache.ts +90 -0
  292. package/src/parsers/ConfluenceParser.ts +950 -0
  293. package/src/parsers/MarkdownParser.ts +1198 -0
  294. package/src/parsers/index.ts +8 -0
  295. package/src/schemas/ConfluenceSchema.ts +56 -0
  296. package/src/schemas/ConversionSchema.ts +318 -0
  297. package/src/schemas/MarkdownSchema.ts +56 -0
  298. package/src/schemas/hast/HastFromHtml.ts +153 -0
  299. package/src/schemas/hast/HastSchema.ts +274 -0
  300. package/src/schemas/hast/index.ts +35 -0
  301. package/src/schemas/index.ts +20 -0
  302. package/src/schemas/mdast/MdastFromMarkdown.ts +118 -0
  303. package/src/schemas/mdast/MdastSchema.ts +566 -0
  304. package/src/schemas/mdast/index.ts +59 -0
  305. package/src/schemas/mdast/mdastToString.ts +102 -0
  306. package/src/schemas/nodes/block/BlockSchema.ts +773 -0
  307. package/src/schemas/nodes/block/index.ts +13 -0
  308. package/src/schemas/nodes/index.ts +20 -0
  309. package/src/schemas/nodes/inline/InlineSchema.ts +523 -0
  310. package/src/schemas/nodes/inline/index.ts +14 -0
  311. package/src/schemas/nodes/macro/MacroSchema.ts +226 -0
  312. package/src/schemas/nodes/macro/index.ts +6 -0
  313. package/src/schemas/preprocessing/ConfluencePreprocessor.ts +446 -0
  314. package/src/schemas/preprocessing/index.ts +8 -0
  315. package/src/serializers/ConfluenceSerializer.ts +717 -0
  316. package/src/serializers/MarkdownSerializer.ts +493 -0
  317. package/src/serializers/index.ts +8 -0
  318. package/test/GitService.test.ts +209 -0
  319. package/test/MarkdownConverter.test.ts +37 -3
  320. package/test/Schemas.test.ts +97 -2
  321. package/test/ast/BlockNode.test.ts +265 -0
  322. package/test/ast/Document.test.ts +126 -0
  323. package/test/ast/InlineNode.test.ts +161 -0
  324. package/test/fixtures/integration-test.html.fixture +103 -0
  325. package/test/fixtures/integration-test.md.expected +257 -0
  326. package/test/integration.test.ts +269 -0
  327. package/test/oauthServer.test.ts +50 -0
  328. package/test/parsers/ConfluenceParser.test.ts +283 -0
  329. package/test/schemas/ConfluencePreprocessor.test.ts +180 -0
  330. package/test/schemas/ConversionSchema.test.ts +159 -0
  331. package/test/schemas/HastSchema.test.ts +138 -0
  332. package/test/schemas/MdastSchema.test.ts +145 -0
  333. package/test/schemas/nodes/block/BlockSchema.test.ts +173 -0
  334. package/test/schemas/nodes/inline/InlineSchema.test.ts +198 -0
  335. package/test/schemas/nodes/macro/MacroSchema.test.ts +142 -0
  336. package/test/tokenStorage.test.ts +99 -0
@@ -0,0 +1,319 @@
1
+ /**
2
+ * Block-level AST node types for structural content.
3
+ *
4
+ * @module
5
+ */
6
+ import * as Schema from "effect/Schema";
7
+ import { InlineNode } from "./InlineNode.js";
8
+ /**
9
+ * Schema version for migration support.
10
+ *
11
+ * @category Version
12
+ */
13
+ export const SchemaVersion = Schema.Number.pipe(Schema.int(), Schema.positive(), Schema.optionalWith({ default: () => 1 }));
14
+ /**
15
+ * Optional raw Confluence HTML for exact roundtrip preservation.
16
+ * When present, the Confluence serializer will output this instead of reconstructing.
17
+ *
18
+ * @category BlockNode
19
+ */
20
+ export const RawConfluence = Schema.optional(Schema.String);
21
+ /**
22
+ * Heading element (h1-h6).
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * import { Heading, Text } from "@knpkv/confluence-to-markdown/ast"
27
+ *
28
+ * const h1 = new Heading({
29
+ * level: 1,
30
+ * children: [new Text({ value: "Introduction" })]
31
+ * })
32
+ * ```
33
+ *
34
+ * @category BlockNode
35
+ */
36
+ export class Heading extends Schema.TaggedClass()("Heading", {
37
+ version: SchemaVersion,
38
+ level: Schema.Literal(1, 2, 3, 4, 5, 6),
39
+ children: Schema.Array(InlineNode),
40
+ rawConfluence: RawConfluence
41
+ }) {
42
+ }
43
+ /**
44
+ * Text alignment options.
45
+ *
46
+ * @category BlockNode
47
+ */
48
+ export const TextAlignment = Schema.Literal("left", "center", "right");
49
+ /**
50
+ * Paragraph element with optional alignment and indentation.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * import { Paragraph, Text } from "@knpkv/confluence-to-markdown/ast"
55
+ *
56
+ * const para = new Paragraph({
57
+ * children: [new Text({ value: "Hello world" })]
58
+ * })
59
+ *
60
+ * // With alignment
61
+ * const centered = new Paragraph({
62
+ * alignment: "center",
63
+ * children: [new Text({ value: "Centered text" })]
64
+ * })
65
+ *
66
+ * // With indentation (in pixels)
67
+ * const indented = new Paragraph({
68
+ * indent: 30,
69
+ * children: [new Text({ value: "Indented text" })]
70
+ * })
71
+ * ```
72
+ *
73
+ * @category BlockNode
74
+ */
75
+ export class Paragraph extends Schema.TaggedClass()("Paragraph", {
76
+ version: SchemaVersion,
77
+ alignment: Schema.optional(TextAlignment),
78
+ indent: Schema.optional(Schema.Number),
79
+ children: Schema.Array(InlineNode),
80
+ rawConfluence: RawConfluence
81
+ }) {
82
+ }
83
+ /**
84
+ * Code block with optional language.
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * import { CodeBlock } from "@knpkv/confluence-to-markdown/ast"
89
+ *
90
+ * const code = new CodeBlock({
91
+ * language: "typescript",
92
+ * code: "const x = 1"
93
+ * })
94
+ * ```
95
+ *
96
+ * @category BlockNode
97
+ */
98
+ export class CodeBlock extends Schema.TaggedClass()("CodeBlock", {
99
+ version: SchemaVersion,
100
+ language: Schema.optional(Schema.String),
101
+ code: Schema.String,
102
+ rawConfluence: RawConfluence
103
+ }) {
104
+ }
105
+ /**
106
+ * Thematic break / horizontal rule.
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * import { ThematicBreak } from "@knpkv/confluence-to-markdown/ast"
111
+ *
112
+ * const hr = new ThematicBreak({})
113
+ * ```
114
+ *
115
+ * @category BlockNode
116
+ */
117
+ export class ThematicBreak extends Schema.TaggedClass()("ThematicBreak", {
118
+ rawConfluence: RawConfluence
119
+ }) {
120
+ }
121
+ /**
122
+ * Attachment reference for images stored in Confluence.
123
+ *
124
+ * @category BlockNode
125
+ */
126
+ export const ImageAttachment = Schema.Struct({
127
+ filename: Schema.String,
128
+ version: Schema.optional(Schema.Number)
129
+ });
130
+ /**
131
+ * Image element with support for both URL and Confluence attachments.
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * import { Image } from "@knpkv/confluence-to-markdown/ast"
136
+ *
137
+ * // URL-based image
138
+ * const img = new Image({
139
+ * src: "https://example.com/image.png",
140
+ * alt: "Example image"
141
+ * })
142
+ *
143
+ * // Confluence attachment
144
+ * const attachment = new Image({
145
+ * attachment: { filename: "logo.svg" },
146
+ * align: "center",
147
+ * width: 250
148
+ * })
149
+ * ```
150
+ *
151
+ * @category BlockNode
152
+ */
153
+ export class Image extends Schema.TaggedClass()("Image", {
154
+ version: SchemaVersion,
155
+ src: Schema.optional(Schema.String),
156
+ attachment: Schema.optional(ImageAttachment),
157
+ alt: Schema.optional(Schema.String),
158
+ title: Schema.optional(Schema.String),
159
+ align: Schema.optional(Schema.String),
160
+ width: Schema.optional(Schema.Number),
161
+ rawConfluence: RawConfluence
162
+ }) {
163
+ }
164
+ /**
165
+ * Table cell element.
166
+ *
167
+ * @example
168
+ * ```typescript
169
+ * import { TableCell, Text } from "@knpkv/confluence-to-markdown/ast"
170
+ *
171
+ * const cell = new TableCell({
172
+ * isHeader: true,
173
+ * children: [new Text({ value: "Header" })]
174
+ * })
175
+ * ```
176
+ *
177
+ * @category BlockNode
178
+ */
179
+ export class TableCell extends Schema.TaggedClass()("TableCell", {
180
+ isHeader: Schema.optionalWith(Schema.Boolean, { default: () => false }),
181
+ children: Schema.Array(InlineNode),
182
+ rawConfluence: RawConfluence
183
+ }) {
184
+ }
185
+ /**
186
+ * Table row element.
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * import { TableRow, TableCell, Text } from "@knpkv/confluence-to-markdown/ast"
191
+ *
192
+ * const row = new TableRow({
193
+ * cells: [
194
+ * new TableCell({ children: [new Text({ value: "A" })] }),
195
+ * new TableCell({ children: [new Text({ value: "B" })] })
196
+ * ]
197
+ * })
198
+ * ```
199
+ *
200
+ * @category BlockNode
201
+ */
202
+ export class TableRow extends Schema.TaggedClass()("TableRow", {
203
+ cells: Schema.Array(TableCell),
204
+ rawConfluence: RawConfluence
205
+ }) {
206
+ }
207
+ /**
208
+ * Table element with optional header row.
209
+ *
210
+ * @example
211
+ * ```typescript
212
+ * import { Table, TableRow, TableCell, Text } from "@knpkv/confluence-to-markdown/ast"
213
+ *
214
+ * const table = new Table({
215
+ * header: new TableRow({
216
+ * cells: [new TableCell({ isHeader: true, children: [new Text({ value: "Col" })] })]
217
+ * }),
218
+ * rows: []
219
+ * })
220
+ * ```
221
+ *
222
+ * @category BlockNode
223
+ */
224
+ export class Table extends Schema.TaggedClass()("Table", {
225
+ version: SchemaVersion,
226
+ header: Schema.optional(TableRow),
227
+ rows: Schema.Array(TableRow),
228
+ rawConfluence: RawConfluence
229
+ }) {
230
+ }
231
+ /**
232
+ * Unsupported block element - preserves raw content for round-tripping.
233
+ *
234
+ * @example
235
+ * ```typescript
236
+ * import { UnsupportedBlock } from "@knpkv/confluence-to-markdown/ast"
237
+ *
238
+ * const unknown = new UnsupportedBlock({
239
+ * rawHtml: "<custom-block>content</custom-block>",
240
+ * source: "confluence"
241
+ * })
242
+ * ```
243
+ *
244
+ * @category BlockNode
245
+ */
246
+ export class UnsupportedBlock extends Schema.TaggedClass()("UnsupportedBlock", {
247
+ rawHtml: Schema.optional(Schema.String),
248
+ rawMarkdown: Schema.optional(Schema.String),
249
+ source: Schema.Literal("confluence", "markdown")
250
+ }) {
251
+ }
252
+ // Non-recursive block nodes
253
+ const SimpleBlockNode = Schema.Union(Heading, Paragraph, CodeBlock, ThematicBreak, Image, Table, UnsupportedBlock);
254
+ /**
255
+ * Block quote element with nested block content.
256
+ *
257
+ * @category BlockNode
258
+ */
259
+ export const BlockQuote = Schema.Struct({
260
+ _tag: Schema.Literal("BlockQuote"),
261
+ version: SchemaVersion,
262
+ children: Schema.Array(SimpleBlockNode),
263
+ rawConfluence: RawConfluence
264
+ });
265
+ /**
266
+ * List item with nested block content.
267
+ *
268
+ * @category BlockNode
269
+ */
270
+ export const ListItem = Schema.Struct({
271
+ _tag: Schema.Literal("ListItem"),
272
+ checked: Schema.optional(Schema.Boolean),
273
+ children: Schema.Array(SimpleBlockNode),
274
+ rawConfluence: RawConfluence
275
+ });
276
+ /**
277
+ * List element (ordered or unordered).
278
+ *
279
+ * @category BlockNode
280
+ */
281
+ export const List = Schema.Struct({
282
+ _tag: Schema.Literal("List"),
283
+ version: SchemaVersion,
284
+ ordered: Schema.Boolean,
285
+ start: Schema.optional(Schema.Number),
286
+ children: Schema.Array(ListItem),
287
+ rawConfluence: RawConfluence
288
+ });
289
+ /**
290
+ * Task item with status for Confluence task lists.
291
+ *
292
+ * @category BlockNode
293
+ */
294
+ export const TaskItem = Schema.Struct({
295
+ _tag: Schema.Literal("TaskItem"),
296
+ id: Schema.String,
297
+ uuid: Schema.String,
298
+ status: Schema.Literal("incomplete", "complete"),
299
+ body: Schema.Array(InlineNode),
300
+ rawConfluence: RawConfluence
301
+ });
302
+ /**
303
+ * Task list (Confluence action items).
304
+ *
305
+ * @category BlockNode
306
+ */
307
+ export const TaskList = Schema.Struct({
308
+ _tag: Schema.Literal("TaskList"),
309
+ version: SchemaVersion,
310
+ children: Schema.Array(TaskItem),
311
+ rawConfluence: RawConfluence
312
+ });
313
+ /**
314
+ * Union of all block node types.
315
+ *
316
+ * @category BlockNode
317
+ */
318
+ export const BlockNode = Schema.Union(Heading, Paragraph, CodeBlock, ThematicBreak, BlockQuote, Image, Table, List, TaskList, UnsupportedBlock);
319
+ //# sourceMappingURL=BlockNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlockNode.js","sourceRoot":"","sources":["../../src/ast/BlockNode.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,UAAU,EAAqC,MAAM,iBAAiB,CAAA;AAE/E;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAC7C,MAAM,CAAC,GAAG,EAAE,EACZ,MAAM,CAAC,QAAQ,EAAE,EACjB,MAAM,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAC1C,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;AAE3D;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,OAAQ,SAAQ,MAAM,CAAC,WAAW,EAAW,CAAC,SAAS,EAAE;IACpE,OAAO,EAAE,aAAa;IACtB,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAA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,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;IAC5B,OAAO,EAAE,aAAa;IACtB,OAAO,EAAE,MAAM,CAAC,OAAO;IACvB,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;IAChC,aAAa,EAAE,aAAa;CAC7B,CAAC,CAAA;AASF;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;IAChC,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,UAAU,CAAC;IAChD,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC;IAC9B,aAAa,EAAE,aAAa;CAC7B,CAAC,CAAA;AASF;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;IAChC,OAAO,EAAE,aAAa;IACtB,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;IAChC,aAAa,EAAE,aAAa;CAC7B,CAAC,CAAA;AASF;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CACnC,OAAO,EACP,SAAS,EACT,SAAS,EACT,aAAa,EACb,UAAU,EACV,KAAK,EACL,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,gBAAgB,CACjB,CAAA"}
@@ -0,0 +1,244 @@
1
+ /**
2
+ * Document AST node - the root of the AST tree.
3
+ *
4
+ * @module
5
+ */
6
+ import * as Schema from "effect/Schema";
7
+ import { type BlockNode as BlockNodeType } from "./BlockNode.js";
8
+ import { type MacroNode as MacroNodeType } from "./MacroNode.js";
9
+ /**
10
+ * Document node - represents a Block or Macro node.
11
+ *
12
+ * @category Document
13
+ */
14
+ export declare const DocumentNode: Schema.Union<[Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, Schema.Struct<{
15
+ _tag: Schema.Literal<["BlockQuote"]>;
16
+ version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
17
+ default: () => number;
18
+ }>;
19
+ children: Schema.Array$<Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, typeof import("./BlockNode.js").UnsupportedBlock]>>;
20
+ rawConfluence: Schema.optional<typeof Schema.String>;
21
+ }>, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, Schema.Struct<{
22
+ _tag: Schema.Literal<["List"]>;
23
+ version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
24
+ default: () => number;
25
+ }>;
26
+ ordered: typeof Schema.Boolean;
27
+ start: Schema.optional<typeof Schema.Number>;
28
+ children: Schema.Array$<Schema.Struct<{
29
+ _tag: Schema.Literal<["ListItem"]>;
30
+ checked: Schema.optional<typeof Schema.Boolean>;
31
+ children: Schema.Array$<Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, typeof import("./BlockNode.js").UnsupportedBlock]>>;
32
+ rawConfluence: Schema.optional<typeof Schema.String>;
33
+ }>>;
34
+ rawConfluence: Schema.optional<typeof Schema.String>;
35
+ }>, Schema.Struct<{
36
+ _tag: Schema.Literal<["TaskList"]>;
37
+ version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
38
+ default: () => number;
39
+ }>;
40
+ children: Schema.Array$<Schema.Struct<{
41
+ _tag: Schema.Literal<["TaskItem"]>;
42
+ id: typeof Schema.String;
43
+ uuid: typeof Schema.String;
44
+ status: Schema.Literal<["incomplete", "complete"]>;
45
+ body: Schema.Array$<Schema.Union<[typeof import("./InlineNode.js").Text, typeof import("./InlineNode.js").Strong, typeof import("./InlineNode.js").Emphasis, typeof import("./InlineNode.js").InlineCode, typeof import("./InlineNode.js").Link, typeof import("./InlineNode.js").LineBreak, typeof import("./InlineNode.js").Emoticon, typeof import("./InlineNode.js").UserMention, typeof import("./InlineNode.js").DateTime, typeof import("./InlineNode.js").Underline, typeof import("./InlineNode.js").Subscript, typeof import("./InlineNode.js").Superscript, typeof import("./InlineNode.js").Strikethrough, typeof import("./InlineNode.js").ColoredText, typeof import("./InlineNode.js").Highlight, typeof import("./InlineNode.js").UnsupportedInline]>>;
46
+ rawConfluence: Schema.optional<typeof Schema.String>;
47
+ }>>;
48
+ rawConfluence: Schema.optional<typeof Schema.String>;
49
+ }>, typeof import("./BlockNode.js").UnsupportedBlock]>, Schema.Union<[Schema.Struct<{
50
+ _tag: Schema.Literal<["InfoPanel"]>;
51
+ version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
52
+ default: () => number;
53
+ }>;
54
+ panelType: Schema.Literal<["info", "warning", "note", "tip", "error", "panel"]>;
55
+ title: Schema.optional<typeof Schema.String>;
56
+ children: Schema.Array$<Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, typeof import("./BlockNode.js").UnsupportedBlock]>>;
57
+ rawConfluence: Schema.optional<typeof Schema.String>;
58
+ }>, Schema.Struct<{
59
+ _tag: Schema.Literal<["ExpandMacro"]>;
60
+ version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
61
+ default: () => number;
62
+ }>;
63
+ title: Schema.optional<typeof Schema.String>;
64
+ children: Schema.Array$<Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, typeof import("./BlockNode.js").UnsupportedBlock]>>;
65
+ rawConfluence: Schema.optional<typeof Schema.String>;
66
+ }>, Schema.Struct<{
67
+ _tag: Schema.Literal<["TocMacro"]>;
68
+ version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
69
+ default: () => number;
70
+ }>;
71
+ minLevel: Schema.optional<typeof Schema.Number>;
72
+ maxLevel: Schema.optional<typeof Schema.Number>;
73
+ rawConfluence: Schema.optional<typeof Schema.String>;
74
+ }>, Schema.Struct<{
75
+ _tag: Schema.Literal<["CodeMacro"]>;
76
+ version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
77
+ default: () => number;
78
+ }>;
79
+ language: Schema.optional<typeof Schema.String>;
80
+ title: Schema.optional<typeof Schema.String>;
81
+ code: typeof Schema.String;
82
+ lineNumbers: Schema.optionalWith<typeof Schema.Boolean, {
83
+ default: () => false;
84
+ }>;
85
+ collapse: Schema.optionalWith<typeof Schema.Boolean, {
86
+ default: () => false;
87
+ }>;
88
+ firstLine: Schema.optional<typeof Schema.Number>;
89
+ rawConfluence: Schema.optional<typeof Schema.String>;
90
+ }>, Schema.Struct<{
91
+ _tag: Schema.Literal<["StatusMacro"]>;
92
+ version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
93
+ default: () => number;
94
+ }>;
95
+ text: typeof Schema.String;
96
+ color: Schema.Literal<["Grey", "Red", "Yellow", "Green", "Blue"]>;
97
+ rawConfluence: Schema.optional<typeof Schema.String>;
98
+ }>]>]>;
99
+ /**
100
+ * Type for document nodes.
101
+ *
102
+ * @category Types
103
+ */
104
+ export type DocumentNode = BlockNodeType | MacroNodeType;
105
+ /**
106
+ * Document schema - the root AST node.
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * import { Document, Heading, Paragraph, Text } from "@knpkv/confluence-to-markdown/ast"
111
+ * import * as Schema from "effect/Schema"
112
+ *
113
+ * const doc = {
114
+ * version: 1,
115
+ * children: [
116
+ * new Heading({ level: 1, children: [new Text({ value: "Title" })] }),
117
+ * new Paragraph({ children: [new Text({ value: "Content" })] })
118
+ * ]
119
+ * }
120
+ *
121
+ * const validated = Schema.decodeUnknownSync(Document)(doc)
122
+ * ```
123
+ *
124
+ * @category Document
125
+ */
126
+ export declare const Document: Schema.Struct<{
127
+ version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
128
+ default: () => number;
129
+ }>;
130
+ children: Schema.Array$<Schema.Union<[Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, Schema.Struct<{
131
+ _tag: Schema.Literal<["BlockQuote"]>;
132
+ version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
133
+ default: () => number;
134
+ }>;
135
+ children: Schema.Array$<Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, typeof import("./BlockNode.js").UnsupportedBlock]>>;
136
+ rawConfluence: Schema.optional<typeof Schema.String>;
137
+ }>, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, Schema.Struct<{
138
+ _tag: Schema.Literal<["List"]>;
139
+ version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
140
+ default: () => number;
141
+ }>;
142
+ ordered: typeof Schema.Boolean;
143
+ start: Schema.optional<typeof Schema.Number>;
144
+ children: Schema.Array$<Schema.Struct<{
145
+ _tag: Schema.Literal<["ListItem"]>;
146
+ checked: Schema.optional<typeof Schema.Boolean>;
147
+ children: Schema.Array$<Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, typeof import("./BlockNode.js").UnsupportedBlock]>>;
148
+ rawConfluence: Schema.optional<typeof Schema.String>;
149
+ }>>;
150
+ rawConfluence: Schema.optional<typeof Schema.String>;
151
+ }>, Schema.Struct<{
152
+ _tag: Schema.Literal<["TaskList"]>;
153
+ version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
154
+ default: () => number;
155
+ }>;
156
+ children: Schema.Array$<Schema.Struct<{
157
+ _tag: Schema.Literal<["TaskItem"]>;
158
+ id: typeof Schema.String;
159
+ uuid: typeof Schema.String;
160
+ status: Schema.Literal<["incomplete", "complete"]>;
161
+ body: Schema.Array$<Schema.Union<[typeof import("./InlineNode.js").Text, typeof import("./InlineNode.js").Strong, typeof import("./InlineNode.js").Emphasis, typeof import("./InlineNode.js").InlineCode, typeof import("./InlineNode.js").Link, typeof import("./InlineNode.js").LineBreak, typeof import("./InlineNode.js").Emoticon, typeof import("./InlineNode.js").UserMention, typeof import("./InlineNode.js").DateTime, typeof import("./InlineNode.js").Underline, typeof import("./InlineNode.js").Subscript, typeof import("./InlineNode.js").Superscript, typeof import("./InlineNode.js").Strikethrough, typeof import("./InlineNode.js").ColoredText, typeof import("./InlineNode.js").Highlight, typeof import("./InlineNode.js").UnsupportedInline]>>;
162
+ rawConfluence: Schema.optional<typeof Schema.String>;
163
+ }>>;
164
+ rawConfluence: Schema.optional<typeof Schema.String>;
165
+ }>, typeof import("./BlockNode.js").UnsupportedBlock]>, Schema.Union<[Schema.Struct<{
166
+ _tag: Schema.Literal<["InfoPanel"]>;
167
+ version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
168
+ default: () => number;
169
+ }>;
170
+ panelType: Schema.Literal<["info", "warning", "note", "tip", "error", "panel"]>;
171
+ title: Schema.optional<typeof Schema.String>;
172
+ children: Schema.Array$<Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, typeof import("./BlockNode.js").UnsupportedBlock]>>;
173
+ rawConfluence: Schema.optional<typeof Schema.String>;
174
+ }>, Schema.Struct<{
175
+ _tag: Schema.Literal<["ExpandMacro"]>;
176
+ version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
177
+ default: () => number;
178
+ }>;
179
+ title: Schema.optional<typeof Schema.String>;
180
+ children: Schema.Array$<Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, typeof import("./BlockNode.js").UnsupportedBlock]>>;
181
+ rawConfluence: Schema.optional<typeof Schema.String>;
182
+ }>, Schema.Struct<{
183
+ _tag: Schema.Literal<["TocMacro"]>;
184
+ version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
185
+ default: () => number;
186
+ }>;
187
+ minLevel: Schema.optional<typeof Schema.Number>;
188
+ maxLevel: Schema.optional<typeof Schema.Number>;
189
+ rawConfluence: Schema.optional<typeof Schema.String>;
190
+ }>, Schema.Struct<{
191
+ _tag: Schema.Literal<["CodeMacro"]>;
192
+ version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
193
+ default: () => number;
194
+ }>;
195
+ language: Schema.optional<typeof Schema.String>;
196
+ title: Schema.optional<typeof Schema.String>;
197
+ code: typeof Schema.String;
198
+ lineNumbers: Schema.optionalWith<typeof Schema.Boolean, {
199
+ default: () => false;
200
+ }>;
201
+ collapse: Schema.optionalWith<typeof Schema.Boolean, {
202
+ default: () => false;
203
+ }>;
204
+ firstLine: Schema.optional<typeof Schema.Number>;
205
+ rawConfluence: Schema.optional<typeof Schema.String>;
206
+ }>, Schema.Struct<{
207
+ _tag: Schema.Literal<["StatusMacro"]>;
208
+ version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
209
+ default: () => number;
210
+ }>;
211
+ text: typeof Schema.String;
212
+ color: Schema.Literal<["Grey", "Red", "Yellow", "Green", "Blue"]>;
213
+ rawConfluence: Schema.optional<typeof Schema.String>;
214
+ }>]>]>>;
215
+ rawConfluence: Schema.optional<typeof Schema.String>;
216
+ }>;
217
+ /**
218
+ * Type for Document.
219
+ *
220
+ * @category Types
221
+ */
222
+ export type Document = Schema.Schema.Type<typeof Document>;
223
+ /**
224
+ * Create a new Document with default version.
225
+ *
226
+ * @example
227
+ * ```typescript
228
+ * import { makeDocument, Heading, Text } from "@knpkv/confluence-to-markdown/ast"
229
+ *
230
+ * const doc = makeDocument([
231
+ * new Heading({ level: 1, children: [new Text({ value: "Hello" })] })
232
+ * ])
233
+ * ```
234
+ *
235
+ * @category Constructors
236
+ */
237
+ export declare const makeDocument: (children: ReadonlyArray<DocumentNode>, rawConfluence?: string) => Document;
238
+ /**
239
+ * Check if a node is a Document.
240
+ *
241
+ * @category Guards
242
+ */
243
+ export declare const isDocument: (value: unknown) => value is Document;
244
+ //# sourceMappingURL=Document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Document.d.ts","sourceRoot":"","sources":["../../src/ast/Document.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAa,KAAK,SAAS,IAAI,aAAa,EAAgC,MAAM,gBAAgB,CAAA;AACzG,OAAO,EAAa,KAAK,SAAS,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE3E;;;;GAIG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAqC,CAAA;AAE9D;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,aAAa,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAInB,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,QAAQ,CAAC,CAAA;AAE1D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,GACvB,UAAU,aAAa,CAAC,YAAY,CAAC,EACrC,gBAAgB,MAAM,KACrB,QAID,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,QAIR,CAAA"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Document AST node - the root of the AST tree.
3
+ *
4
+ * @module
5
+ */
6
+ import * as Schema from "effect/Schema";
7
+ import { BlockNode, RawConfluence, SchemaVersion } from "./BlockNode.js";
8
+ import { MacroNode } from "./MacroNode.js";
9
+ /**
10
+ * Document node - represents a Block or Macro node.
11
+ *
12
+ * @category Document
13
+ */
14
+ export const DocumentNode = Schema.Union(BlockNode, MacroNode);
15
+ /**
16
+ * Document schema - the root AST node.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import { Document, Heading, Paragraph, Text } from "@knpkv/confluence-to-markdown/ast"
21
+ * import * as Schema from "effect/Schema"
22
+ *
23
+ * const doc = {
24
+ * version: 1,
25
+ * children: [
26
+ * new Heading({ level: 1, children: [new Text({ value: "Title" })] }),
27
+ * new Paragraph({ children: [new Text({ value: "Content" })] })
28
+ * ]
29
+ * }
30
+ *
31
+ * const validated = Schema.decodeUnknownSync(Document)(doc)
32
+ * ```
33
+ *
34
+ * @category Document
35
+ */
36
+ export const Document = Schema.Struct({
37
+ version: SchemaVersion,
38
+ children: Schema.Array(DocumentNode),
39
+ rawConfluence: RawConfluence
40
+ });
41
+ /**
42
+ * Create a new Document with default version.
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * import { makeDocument, Heading, Text } from "@knpkv/confluence-to-markdown/ast"
47
+ *
48
+ * const doc = makeDocument([
49
+ * new Heading({ level: 1, children: [new Text({ value: "Hello" })] })
50
+ * ])
51
+ * ```
52
+ *
53
+ * @category Constructors
54
+ */
55
+ export const makeDocument = (children, rawConfluence) => ({
56
+ version: 1,
57
+ children,
58
+ ...(rawConfluence !== undefined ? { rawConfluence } : {})
59
+ });
60
+ /**
61
+ * Check if a node is a Document.
62
+ *
63
+ * @category Guards
64
+ */
65
+ export const isDocument = (value) => typeof value === "object" &&
66
+ value !== null &&
67
+ "children" in value &&
68
+ Array.isArray(value.children);
69
+ //# sourceMappingURL=Document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Document.js","sourceRoot":"","sources":["../../src/ast/Document.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,SAAS,EAAmC,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACzG,OAAO,EAAE,SAAS,EAAmC,MAAM,gBAAgB,CAAA;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;AAS9D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,aAAa;IACtB,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC;IACpC,aAAa,EAAE,aAAa;CAC7B,CAAC,CAAA;AASF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,QAAqC,EACrC,aAAsB,EACZ,EAAE,CAAC,CAAC;IACd,OAAO,EAAE,CAAC;IACV,QAAQ;IACR,GAAG,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;CAC1D,CAAC,CAAA;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAc,EAAqB,EAAE,CAC9D,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACd,UAAU,IAAI,KAAK;IACnB,KAAK,CAAC,OAAO,CAAE,KAAkB,CAAC,QAAQ,CAAC,CAAA"}