@knpkv/confluence-to-markdown 0.5.0 → 0.6.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.
Files changed (108) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +45 -10
  3. package/dist/ConfluenceAuth.d.ts.map +1 -1
  4. package/dist/ConfluenceAuth.js +12 -22
  5. package/dist/ConfluenceAuth.js.map +1 -1
  6. package/dist/ConfluenceClient.d.ts +13 -3
  7. package/dist/ConfluenceClient.d.ts.map +1 -1
  8. package/dist/ConfluenceClient.js +34 -70
  9. package/dist/ConfluenceClient.js.map +1 -1
  10. package/dist/ConfluenceError.d.ts +12 -12
  11. package/dist/GitError.d.ts +5 -5
  12. package/dist/GitService.d.ts.map +1 -1
  13. package/dist/GitService.js +0 -3
  14. package/dist/GitService.js.map +1 -1
  15. package/dist/SchemaConverterError.d.ts +3 -3
  16. package/dist/ast/BlockNode.d.ts +48 -33
  17. package/dist/ast/BlockNode.d.ts.map +1 -1
  18. package/dist/ast/BlockNode.js +11 -2
  19. package/dist/ast/BlockNode.js.map +1 -1
  20. package/dist/ast/Document.d.ts +30 -2
  21. package/dist/ast/Document.d.ts.map +1 -1
  22. package/dist/parsers/ConfluenceParser.d.ts.map +1 -1
  23. package/dist/parsers/ConfluenceParser.js +7 -12
  24. package/dist/parsers/ConfluenceParser.js.map +1 -1
  25. package/dist/parsers/MarkdownParser.js +8 -117
  26. package/dist/parsers/MarkdownParser.js.map +1 -1
  27. package/dist/parsers/preprocessing/ConfluencePreprocessing.d.ts +23 -0
  28. package/dist/parsers/preprocessing/ConfluencePreprocessing.d.ts.map +1 -0
  29. package/dist/parsers/preprocessing/ConfluencePreprocessing.js +323 -0
  30. package/dist/parsers/preprocessing/ConfluencePreprocessing.js.map +1 -0
  31. package/dist/parsers/preprocessing/index.d.ts +7 -0
  32. package/dist/parsers/preprocessing/index.d.ts.map +1 -0
  33. package/dist/parsers/preprocessing/index.js +7 -0
  34. package/dist/parsers/preprocessing/index.js.map +1 -0
  35. package/dist/schemas/preprocessing/ConfluencePreprocessor.d.ts +29 -0
  36. package/dist/schemas/preprocessing/ConfluencePreprocessor.d.ts.map +1 -1
  37. package/dist/schemas/preprocessing/ConfluencePreprocessor.js +5 -15
  38. package/dist/schemas/preprocessing/ConfluencePreprocessor.js.map +1 -1
  39. package/dist/serializers/ConfluenceSerializer.js +0 -9
  40. package/dist/serializers/ConfluenceSerializer.js.map +1 -1
  41. package/dist/serializers/MarkdownSerializer.js +9 -49
  42. package/dist/serializers/MarkdownSerializer.js.map +1 -1
  43. package/package.json +35 -26
  44. package/src/AdfPlaceholders.ts +266 -0
  45. package/src/AdfSchemaValidator.ts +67 -0
  46. package/src/AdfWalker.ts +511 -0
  47. package/src/AtlaskitTransformers.ts +72 -0
  48. package/src/ConfluenceClient.ts +4 -4
  49. package/src/ConfluenceError.ts +65 -3
  50. package/src/MarkdownConverter.ts +106 -139
  51. package/src/Schemas.ts +4 -4
  52. package/src/SyncEngine.ts +130 -83
  53. package/src/atlaskit-adf-schema.d.ts +3 -0
  54. package/src/commands/clone.ts +8 -1
  55. package/src/commands/layers.ts +11 -4
  56. package/src/index.ts +3 -18
  57. package/test/AdfPlaceholders.test.ts +295 -0
  58. package/test/AdfSchemaValidator.test.ts +34 -0
  59. package/test/AdfWalker.test.ts +530 -0
  60. package/test/AtlaskitTransformers.test.ts +25 -0
  61. package/test/MarkdownConverter.test.ts +120 -105
  62. package/test/RoundTrip.test.ts +266 -0
  63. package/LICENSE +0 -21
  64. package/src/SchemaConverterError.ts +0 -108
  65. package/src/ast/BlockNode.ts +0 -469
  66. package/src/ast/Document.ts +0 -90
  67. package/src/ast/InlineNode.ts +0 -323
  68. package/src/ast/MacroNode.ts +0 -245
  69. package/src/ast/index.ts +0 -83
  70. package/src/parsers/ConfluenceParser.ts +0 -956
  71. package/src/parsers/MarkdownParser.ts +0 -1338
  72. package/src/parsers/index.ts +0 -8
  73. package/src/schemas/ConfluenceSchema.ts +0 -56
  74. package/src/schemas/ConversionSchema.ts +0 -318
  75. package/src/schemas/MarkdownSchema.ts +0 -56
  76. package/src/schemas/hast/HastFromHtml.ts +0 -153
  77. package/src/schemas/hast/HastSchema.ts +0 -274
  78. package/src/schemas/hast/index.ts +0 -35
  79. package/src/schemas/index.ts +0 -20
  80. package/src/schemas/mdast/MdastFromMarkdown.ts +0 -118
  81. package/src/schemas/mdast/MdastSchema.ts +0 -566
  82. package/src/schemas/mdast/index.ts +0 -59
  83. package/src/schemas/mdast/mdastToString.ts +0 -102
  84. package/src/schemas/nodes/block/BlockSchema.ts +0 -773
  85. package/src/schemas/nodes/block/index.ts +0 -13
  86. package/src/schemas/nodes/index.ts +0 -20
  87. package/src/schemas/nodes/inline/InlineSchema.ts +0 -523
  88. package/src/schemas/nodes/inline/index.ts +0 -14
  89. package/src/schemas/nodes/macro/MacroSchema.ts +0 -226
  90. package/src/schemas/nodes/macro/index.ts +0 -6
  91. package/src/schemas/preprocessing/ConfluencePreprocessor.ts +0 -455
  92. package/src/schemas/preprocessing/index.ts +0 -8
  93. package/src/serializers/ConfluenceSerializer.ts +0 -737
  94. package/src/serializers/MarkdownSerializer.ts +0 -543
  95. package/src/serializers/index.ts +0 -8
  96. package/test/ast/BlockNode.test.ts +0 -265
  97. package/test/ast/Document.test.ts +0 -126
  98. package/test/ast/InlineNode.test.ts +0 -161
  99. package/test/fixtures/integration-test.html.fixture +0 -103
  100. package/test/fixtures/integration-test.md.expected +0 -257
  101. package/test/parsers/ConfluenceParser.test.ts +0 -452
  102. package/test/schemas/ConfluencePreprocessor.test.ts +0 -180
  103. package/test/schemas/ConversionSchema.test.ts +0 -159
  104. package/test/schemas/HastSchema.test.ts +0 -138
  105. package/test/schemas/MdastSchema.test.ts +0 -145
  106. package/test/schemas/nodes/block/BlockSchema.test.ts +0 -173
  107. package/test/schemas/nodes/inline/InlineSchema.test.ts +0 -198
  108. package/test/schemas/nodes/macro/MacroSchema.test.ts +0 -142
@@ -1,198 +0,0 @@
1
- import { describe, expect, it } from "@effect/vitest"
2
- import type { UnsupportedInline } from "../../../../src/ast/InlineNode.js"
3
- import { Emphasis, InlineCode, LineBreak, Link, Strong, Text } from "../../../../src/ast/InlineNode.js"
4
- import { makeHastText } from "../../../../src/schemas/hast/index.js"
5
- import { makeMdastText } from "../../../../src/schemas/mdast/index.js"
6
- import {
7
- inlineNodeFromMdast,
8
- inlineNodeToHast,
9
- inlineNodeToMdast,
10
- textFromHastText
11
- } from "../../../../src/schemas/nodes/inline/index.js"
12
-
13
- describe("InlineSchema", () => {
14
- describe("textFromHastText", () => {
15
- it("converts hast text to Text node", () => {
16
- const hastText = makeHastText("hello")
17
- const result = textFromHastText(hastText)
18
- expect(result._tag).toBe("Text")
19
- expect(result.value).toBe("hello")
20
- })
21
- })
22
-
23
- describe("inlineNodeToHast", () => {
24
- it("converts Text to hast text", () => {
25
- const text = new Text({ value: "hello" })
26
- const result = inlineNodeToHast(text)
27
- expect(result._tag).toBe("text")
28
- expect((result as { value: string }).value).toBe("hello")
29
- })
30
-
31
- it("converts Strong to hast strong", () => {
32
- const strong = new Strong({ children: [new Text({ value: "bold" })] })
33
- const result = inlineNodeToHast(strong)
34
- expect(result._tag).toBe("element")
35
- expect((result as { tagName: string }).tagName).toBe("strong")
36
- })
37
-
38
- it("converts Emphasis to hast em", () => {
39
- const emphasis = new Emphasis({ children: [new Text({ value: "italic" })] })
40
- const result = inlineNodeToHast(emphasis)
41
- expect(result._tag).toBe("element")
42
- expect((result as { tagName: string }).tagName).toBe("em")
43
- })
44
-
45
- it("converts InlineCode to hast code", () => {
46
- const code = new InlineCode({ value: "const x = 1" })
47
- const result = inlineNodeToHast(code)
48
- expect(result._tag).toBe("element")
49
- expect((result as { tagName: string }).tagName).toBe("code")
50
- })
51
-
52
- it("converts Link to hast anchor", () => {
53
- const link = new Link({
54
- href: "https://example.com",
55
- title: "Example",
56
- children: [new Text({ value: "click" })]
57
- })
58
- const result = inlineNodeToHast(link)
59
- expect(result._tag).toBe("element")
60
- expect((result as { tagName: string }).tagName).toBe("a")
61
- })
62
-
63
- it("converts LineBreak to hast br", () => {
64
- const br = new LineBreak({})
65
- const result = inlineNodeToHast(br)
66
- expect(result._tag).toBe("element")
67
- expect((result as { tagName: string }).tagName).toBe("br")
68
- })
69
- })
70
-
71
- describe("inlineNodeToMdast", () => {
72
- it("converts Text to mdast text", () => {
73
- const text = new Text({ value: "hello" })
74
- const result = inlineNodeToMdast(text)
75
- expect(result.type).toBe("text")
76
- expect((result as { value: string }).value).toBe("hello")
77
- })
78
-
79
- it("converts Strong to mdast strong", () => {
80
- const strong = new Strong({ children: [new Text({ value: "bold" })] })
81
- const result = inlineNodeToMdast(strong)
82
- expect(result.type).toBe("strong")
83
- })
84
-
85
- it("converts Emphasis to mdast emphasis", () => {
86
- const emphasis = new Emphasis({ children: [new Text({ value: "italic" })] })
87
- const result = inlineNodeToMdast(emphasis)
88
- expect(result.type).toBe("emphasis")
89
- })
90
-
91
- it("converts InlineCode to mdast inlineCode", () => {
92
- const code = new InlineCode({ value: "x" })
93
- const result = inlineNodeToMdast(code)
94
- expect(result.type).toBe("inlineCode")
95
- expect((result as { value: string }).value).toBe("x")
96
- })
97
-
98
- it("converts Link to mdast link", () => {
99
- const link = new Link({
100
- href: "https://example.com",
101
- children: [new Text({ value: "click" })]
102
- })
103
- const result = inlineNodeToMdast(link)
104
- expect(result.type).toBe("link")
105
- expect((result as { url: string }).url).toBe("https://example.com")
106
- })
107
-
108
- it("converts LineBreak to mdast break", () => {
109
- const br = new LineBreak({})
110
- const result = inlineNodeToMdast(br)
111
- expect(result.type).toBe("break")
112
- })
113
- })
114
-
115
- describe("inlineNodeFromMdast", () => {
116
- it("converts mdast text to Text", () => {
117
- const mdast = makeMdastText("hello")
118
- const result = inlineNodeFromMdast(mdast)
119
- expect(result._tag).toBe("Text")
120
- expect((result as Text).value).toBe("hello")
121
- })
122
-
123
- it("converts mdast strong to Strong", () => {
124
- const mdast = { type: "strong" as const, children: [makeMdastText("bold")] }
125
- const result = inlineNodeFromMdast(mdast)
126
- expect(result._tag).toBe("Strong")
127
- })
128
-
129
- it("converts mdast emphasis to Emphasis", () => {
130
- const mdast = { type: "emphasis" as const, children: [makeMdastText("italic")] }
131
- const result = inlineNodeFromMdast(mdast)
132
- expect(result._tag).toBe("Emphasis")
133
- })
134
-
135
- it("converts mdast inlineCode to InlineCode", () => {
136
- const mdast = { type: "inlineCode" as const, value: "x" }
137
- const result = inlineNodeFromMdast(mdast)
138
- expect(result._tag).toBe("InlineCode")
139
- expect((result as InlineCode).value).toBe("x")
140
- })
141
-
142
- it("converts mdast link to Link", () => {
143
- const mdast = {
144
- type: "link" as const,
145
- url: "https://example.com",
146
- title: null,
147
- children: [makeMdastText("click")]
148
- }
149
- const result = inlineNodeFromMdast(mdast)
150
- expect(result._tag).toBe("Link")
151
- expect((result as Link).href).toBe("https://example.com")
152
- })
153
-
154
- it("converts mdast break to LineBreak", () => {
155
- const mdast = { type: "break" as const }
156
- const result = inlineNodeFromMdast(mdast)
157
- expect(result._tag).toBe("LineBreak")
158
- })
159
-
160
- it("converts mdast delete to Strikethrough", () => {
161
- const mdast = { type: "delete" as const, children: [makeMdastText("deleted")] }
162
- const result = inlineNodeFromMdast(mdast)
163
- expect(result._tag).toBe("Strikethrough")
164
- })
165
-
166
- it("converts mdast html to UnsupportedInline", () => {
167
- const mdast = { type: "html" as const, value: "<custom>x</custom>" }
168
- const result = inlineNodeFromMdast(mdast)
169
- expect(result._tag).toBe("UnsupportedInline")
170
- expect((result as UnsupportedInline).raw).toBe("<custom>x</custom>")
171
- })
172
- })
173
-
174
- describe("roundtrip", () => {
175
- it("Text roundtrips through MDAST", () => {
176
- const original = new Text({ value: "hello" })
177
- const mdast = inlineNodeToMdast(original)
178
- const result = inlineNodeFromMdast(mdast)
179
- expect(result._tag).toBe("Text")
180
- expect((result as Text).value).toBe("hello")
181
- })
182
-
183
- it("Strong roundtrips through MDAST", () => {
184
- const original = new Strong({ children: [new Text({ value: "bold" })] })
185
- const mdast = inlineNodeToMdast(original)
186
- const result = inlineNodeFromMdast(mdast)
187
- expect(result._tag).toBe("Strong")
188
- })
189
-
190
- it("Text roundtrips through HAST", () => {
191
- const original = new Text({ value: "hello" })
192
- const hast = inlineNodeToHast(original)
193
- const result = textFromHastText(hast as { _tag: "text"; value: string })
194
- expect(result._tag).toBe("Text")
195
- expect(result.value).toBe("hello")
196
- })
197
- })
198
- })
@@ -1,142 +0,0 @@
1
- import { describe, expect, it } from "@effect/vitest"
2
- import { Paragraph } from "../../../../src/ast/BlockNode.js"
3
- import { Text } from "../../../../src/ast/InlineNode.js"
4
- import type { CodeMacro, ExpandMacro, InfoPanel, StatusMacro, TocMacro } from "../../../../src/ast/MacroNode.js"
5
- import { macroNodeToHast, macroNodeToMdast } from "../../../../src/schemas/nodes/macro/index.js"
6
-
7
- describe("MacroSchema", () => {
8
- describe("macroNodeToHast", () => {
9
- it("converts InfoPanel to hast div with data attributes", () => {
10
- const panel: InfoPanel = {
11
- _tag: "InfoPanel",
12
- version: 1,
13
- panelType: "warning",
14
- title: "Important",
15
- children: [new Paragraph({ children: [new Text({ value: "Content" })] })]
16
- }
17
- const result = macroNodeToHast(panel)
18
- expect(result._tag).toBe("element")
19
- expect(result.tagName).toBe("div")
20
- expect(result.properties?.dataMacro).toBe("warning")
21
- expect(result.properties?.dataTitle).toBe("Important")
22
- })
23
-
24
- it("converts ExpandMacro to hast details element", () => {
25
- const expand: ExpandMacro = {
26
- _tag: "ExpandMacro",
27
- version: 1,
28
- title: "Click to expand",
29
- children: [new Paragraph({ children: [new Text({ value: "Hidden" })] })]
30
- }
31
- const result = macroNodeToHast(expand)
32
- expect(result._tag).toBe("element")
33
- expect(result.tagName).toBe("details")
34
- })
35
-
36
- it("converts TocMacro to hast nav element", () => {
37
- const toc: TocMacro = {
38
- _tag: "TocMacro",
39
- version: 1,
40
- minLevel: 2,
41
- maxLevel: 4
42
- }
43
- const result = macroNodeToHast(toc)
44
- expect(result._tag).toBe("element")
45
- expect(result.tagName).toBe("nav")
46
- expect(result.properties?.dataMacro).toBe("toc")
47
- expect(result.properties?.dataMin).toBe("2")
48
- expect(result.properties?.dataMax).toBe("4")
49
- })
50
-
51
- it("converts CodeMacro to hast pre/code elements", () => {
52
- const code: CodeMacro = {
53
- _tag: "CodeMacro",
54
- version: 1,
55
- language: "typescript",
56
- code: "const x = 1",
57
- lineNumbers: false,
58
- collapse: false
59
- }
60
- const result = macroNodeToHast(code)
61
- expect(result._tag).toBe("element")
62
- expect(result.tagName).toBe("pre")
63
- expect(result.properties?.dataLanguage).toBe("typescript")
64
- })
65
-
66
- it("converts StatusMacro to hast span element", () => {
67
- const status: StatusMacro = {
68
- _tag: "StatusMacro",
69
- version: 1,
70
- text: "Done",
71
- color: "Green"
72
- }
73
- const result = macroNodeToHast(status)
74
- expect(result._tag).toBe("element")
75
- expect(result.tagName).toBe("span")
76
- expect(result.properties?.dataMacro).toBe("status")
77
- expect(result.properties?.dataColor).toBe("Green")
78
- })
79
- })
80
-
81
- describe("macroNodeToMdast", () => {
82
- it("converts InfoPanel to mdast html with container syntax", () => {
83
- const panel: InfoPanel = {
84
- _tag: "InfoPanel",
85
- version: 1,
86
- panelType: "info",
87
- children: [new Paragraph({ children: [new Text({ value: "Note content" })] })]
88
- }
89
- const result = macroNodeToMdast(panel)
90
- expect(result.type).toBe("html")
91
- expect((result as { value: string }).value).toContain(":::info")
92
- })
93
-
94
- it("converts ExpandMacro to mdast html with details element", () => {
95
- const expand: ExpandMacro = {
96
- _tag: "ExpandMacro",
97
- version: 1,
98
- title: "More info",
99
- children: []
100
- }
101
- const result = macroNodeToMdast(expand)
102
- expect(result.type).toBe("html")
103
- expect((result as { value: string }).value).toContain("<details>")
104
- expect((result as { value: string }).value).toContain("More info")
105
- })
106
-
107
- it("converts TocMacro to mdast html with toc marker", () => {
108
- const toc: TocMacro = {
109
- _tag: "TocMacro",
110
- version: 1
111
- }
112
- const result = macroNodeToMdast(toc)
113
- expect(result.type).toBe("html")
114
- expect((result as { value: string }).value).toBe("[[toc]]")
115
- })
116
-
117
- it("converts CodeMacro to mdast code", () => {
118
- const code: CodeMacro = {
119
- _tag: "CodeMacro",
120
- version: 1,
121
- language: "py",
122
- code: "print(1)",
123
- lineNumbers: false,
124
- collapse: false
125
- }
126
- const result = macroNodeToMdast(code)
127
- expect(result.type).toBe("code")
128
- expect((result as { value: string }).value).toBe("print(1)")
129
- })
130
-
131
- it("converts StatusMacro to mdast paragraph with badge text", () => {
132
- const status: StatusMacro = {
133
- _tag: "StatusMacro",
134
- version: 1,
135
- text: "In Progress",
136
- color: "Blue"
137
- }
138
- const result = macroNodeToMdast(status)
139
- expect(result.type).toBe("paragraph")
140
- })
141
- })
142
- })