@knpkv/confluence-to-markdown 0.5.0 → 0.7.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.
- package/CHANGELOG.md +61 -0
- package/README.md +58 -14
- package/dist/AdfPlaceholders.d.ts +42 -0
- package/dist/AdfPlaceholders.d.ts.map +1 -0
- package/dist/AdfPlaceholders.js +547 -0
- package/dist/AdfPlaceholders.js.map +1 -0
- package/dist/AdfSchemaValidator.d.ts +37 -0
- package/dist/AdfSchemaValidator.d.ts.map +1 -0
- package/dist/AdfSchemaValidator.js +37 -0
- package/dist/AdfSchemaValidator.js.map +1 -0
- package/dist/AdfWalker.d.ts +39 -0
- package/dist/AdfWalker.d.ts.map +1 -0
- package/dist/AdfWalker.js +527 -0
- package/dist/AdfWalker.js.map +1 -0
- package/dist/AtlaskitTransformers.d.ts +35 -0
- package/dist/AtlaskitTransformers.d.ts.map +1 -0
- package/dist/AtlaskitTransformers.js +48 -0
- package/dist/AtlaskitTransformers.js.map +1 -0
- package/dist/Brand.d.ts +6 -6
- package/dist/Brand.d.ts.map +1 -1
- package/dist/Brand.js +8 -6
- package/dist/Brand.js.map +1 -1
- package/dist/ConfluenceAuth.d.ts +4 -4
- package/dist/ConfluenceAuth.d.ts.map +1 -1
- package/dist/ConfluenceAuth.js +15 -27
- package/dist/ConfluenceAuth.js.map +1 -1
- package/dist/ConfluenceClient.d.ts +4 -4
- package/dist/ConfluenceClient.d.ts.map +1 -1
- package/dist/ConfluenceClient.js +21 -14
- package/dist/ConfluenceClient.js.map +1 -1
- package/dist/ConfluenceConfig.d.ts +3 -3
- package/dist/ConfluenceConfig.d.ts.map +1 -1
- package/dist/ConfluenceConfig.js +13 -11
- package/dist/ConfluenceConfig.js.map +1 -1
- package/dist/ConfluenceError.d.ts +56 -4
- package/dist/ConfluenceError.d.ts.map +1 -1
- package/dist/ConfluenceError.js +30 -1
- package/dist/ConfluenceError.js.map +1 -1
- package/dist/GitService.d.ts +11 -3
- package/dist/GitService.d.ts.map +1 -1
- package/dist/GitService.js +19 -27
- package/dist/GitService.js.map +1 -1
- package/dist/LocalFileSystem.d.ts +3 -3
- package/dist/LocalFileSystem.d.ts.map +1 -1
- package/dist/LocalFileSystem.js +6 -6
- package/dist/LocalFileSystem.js.map +1 -1
- package/dist/MarkdownConverter.d.ts +16 -65
- package/dist/MarkdownConverter.d.ts.map +1 -1
- package/dist/MarkdownConverter.js +64 -85
- package/dist/MarkdownConverter.js.map +1 -1
- package/dist/Schemas.d.ts +128 -141
- package/dist/Schemas.d.ts.map +1 -1
- package/dist/Schemas.js +21 -23
- package/dist/Schemas.js.map +1 -1
- package/dist/SyncEngine.d.ts +8 -5
- package/dist/SyncEngine.d.ts.map +1 -1
- package/dist/SyncEngine.js +189 -113
- package/dist/SyncEngine.js.map +1 -1
- package/dist/bin.js +23 -35
- package/dist/bin.js.map +1 -1
- package/dist/commands/auth.d.ts +2 -14
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +11 -16
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/clone.d.ts +4 -6
- package/dist/commands/clone.d.ts.map +1 -1
- package/dist/commands/clone.js +34 -32
- package/dist/commands/clone.js.map +1 -1
- package/dist/commands/delete.d.ts +2 -10
- package/dist/commands/delete.d.ts.map +1 -1
- package/dist/commands/delete.js +5 -4
- package/dist/commands/delete.js.map +1 -1
- package/dist/commands/errorHandler.d.ts +2 -1
- package/dist/commands/errorHandler.d.ts.map +1 -1
- package/dist/commands/errorHandler.js +22 -15
- package/dist/commands/errorHandler.js.map +1 -1
- package/dist/commands/fetch.d.ts +27 -0
- package/dist/commands/fetch.d.ts.map +1 -0
- package/dist/commands/fetch.js +48 -0
- package/dist/commands/fetch.js.map +1 -0
- package/dist/commands/git.d.ts +7 -10
- package/dist/commands/git.d.ts.map +1 -1
- package/dist/commands/git.js +6 -6
- package/dist/commands/git.js.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/layers.d.ts +10 -9
- package/dist/commands/layers.d.ts.map +1 -1
- package/dist/commands/layers.js +41 -30
- package/dist/commands/layers.js.map +1 -1
- package/dist/commands/new.d.ts +2 -6
- package/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +5 -4
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/pageInput.d.ts +19 -0
- package/dist/commands/pageInput.d.ts.map +1 -0
- package/dist/commands/pageInput.js +68 -0
- package/dist/commands/pageInput.js.map +1 -0
- package/dist/commands/root.d.ts +8 -0
- package/dist/commands/root.d.ts.map +1 -0
- package/dist/commands/root.js +29 -0
- package/dist/commands/root.js.map +1 -0
- package/dist/commands/sync.d.ts +6 -9
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +5 -6
- package/dist/commands/sync.js.map +1 -1
- package/dist/index.d.ts +3 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -13
- package/dist/index.js.map +1 -1
- package/dist/internal/NodeLayers.d.ts.map +1 -1
- package/dist/internal/NodeLayers.js +1 -2
- package/dist/internal/NodeLayers.js.map +1 -1
- package/dist/internal/adfMetadata.d.ts +30 -0
- package/dist/internal/adfMetadata.d.ts.map +1 -0
- package/dist/internal/adfMetadata.js +126 -0
- package/dist/internal/adfMetadata.js.map +1 -0
- package/dist/internal/cleanMarkdown.d.ts +5 -0
- package/dist/internal/cleanMarkdown.d.ts.map +1 -0
- package/dist/internal/cleanMarkdown.js +13 -0
- package/dist/internal/cleanMarkdown.js.map +1 -0
- package/dist/internal/frontmatter.d.ts.map +1 -1
- package/dist/internal/frontmatter.js +41 -8
- package/dist/internal/frontmatter.js.map +1 -1
- package/dist/internal/gitCommands.d.ts +9 -3
- package/dist/internal/gitCommands.d.ts.map +1 -1
- package/dist/internal/gitCommands.js +18 -9
- package/dist/internal/gitCommands.js.map +1 -1
- package/dist/internal/hashUtils.d.ts +1 -1
- package/dist/internal/hashUtils.d.ts.map +1 -1
- package/dist/internal/hashUtils.js +1 -1
- package/dist/internal/hashUtils.js.map +1 -1
- package/dist/internal/oauthServer.d.ts +10 -5
- package/dist/internal/oauthServer.d.ts.map +1 -1
- package/dist/internal/oauthServer.js +19 -40
- package/dist/internal/oauthServer.js.map +1 -1
- package/dist/internal/pathUtils.d.ts +1 -1
- package/dist/internal/pathUtils.d.ts.map +1 -1
- package/dist/internal/pathUtils.js +1 -1
- package/dist/internal/pathUtils.js.map +1 -1
- package/dist/internal/process.d.ts +15 -0
- package/dist/internal/process.d.ts.map +1 -0
- package/dist/internal/process.js +10 -0
- package/dist/internal/process.js.map +1 -0
- package/dist/internal/stdio.d.ts +6 -0
- package/dist/internal/stdio.d.ts.map +1 -0
- package/dist/internal/stdio.js +15 -0
- package/dist/internal/stdio.js.map +1 -0
- package/dist/internal/tokenStorage.d.ts +3 -13
- package/dist/internal/tokenStorage.d.ts.map +1 -1
- package/dist/internal/tokenStorage.js +26 -24
- package/dist/internal/tokenStorage.js.map +1 -1
- package/dist/internal/userCache.d.ts +1 -1
- package/dist/internal/userCache.d.ts.map +1 -1
- package/dist/internal/userCache.js +1 -1
- package/dist/internal/userCache.js.map +1 -1
- package/package.json +29 -20
- package/skills/confluence/SKILL.md +143 -0
- package/skills/confluence/agents/openai.yaml +4 -0
- package/src/AdfPlaceholders.ts +563 -0
- package/src/AdfSchemaValidator.ts +65 -0
- package/src/AdfWalker.ts +591 -0
- package/src/AtlaskitTransformers.ts +70 -0
- package/src/Brand.ts +11 -16
- package/src/ConfluenceAuth.ts +22 -30
- package/src/ConfluenceClient.ts +28 -24
- package/src/ConfluenceConfig.ts +14 -14
- package/src/ConfluenceError.ts +65 -3
- package/src/GitService.ts +39 -49
- package/src/LocalFileSystem.ts +7 -9
- package/src/MarkdownConverter.ts +108 -143
- package/src/Schemas.ts +17 -16
- package/src/SyncEngine.ts +272 -127
- package/src/atlaskit-adf-schema.d.ts +3 -0
- package/src/bin.ts +30 -56
- package/src/commands/auth.ts +21 -18
- package/src/commands/clone.ts +46 -38
- package/src/commands/delete.ts +5 -4
- package/src/commands/errorHandler.ts +25 -18
- package/src/commands/fetch.ts +90 -0
- package/src/commands/git.ts +6 -6
- package/src/commands/index.ts +1 -0
- package/src/commands/layers.ts +64 -37
- package/src/commands/new.ts +5 -4
- package/src/commands/pageInput.ts +103 -0
- package/src/commands/root.ts +59 -0
- package/src/commands/sync.ts +7 -6
- package/src/index.ts +3 -18
- package/src/internal/NodeLayers.ts +1 -2
- package/src/internal/adfMetadata.ts +145 -0
- package/src/internal/cleanMarkdown.ts +15 -0
- package/src/internal/frontmatter.ts +45 -8
- package/src/internal/gitCommands.ts +23 -17
- package/src/internal/hashUtils.ts +2 -2
- package/src/internal/oauthServer.ts +84 -105
- package/src/internal/pathUtils.ts +1 -1
- package/src/internal/process.ts +15 -0
- package/src/internal/stdio.ts +22 -0
- package/src/internal/tokenStorage.ts +39 -29
- package/src/internal/userCache.ts +2 -2
- package/test/AdfPlaceholders.test.ts +508 -0
- package/test/AdfSchemaValidator.test.ts +34 -0
- package/test/AdfWalker.test.ts +676 -0
- package/test/AtlaskitTransformers.test.ts +25 -0
- package/test/Brand.test.ts +11 -11
- package/test/GitService.test.ts +6 -2
- package/test/MarkdownConverter.test.ts +121 -105
- package/test/RoundTrip.test.ts +521 -0
- package/test/Schemas.test.ts +40 -40
- package/test/adfMetadata.test.ts +110 -0
- package/test/cleanMarkdown.test.ts +36 -0
- package/test/commandHarness.test.ts +79 -0
- package/test/commandHarness.ts +147 -0
- package/test/fetch.test.ts +61 -0
- package/test/frontmatter.test.ts +41 -0
- package/test/integration.test.ts +569 -156
- package/test/layers.test.ts +12 -0
- package/test/oauthServer.test.ts +4 -5
- package/test/pageInput.test.ts +83 -0
- package/test/tokenStorage.test.ts +17 -17
- package/dist/SchemaConverterError.d.ts +0 -108
- package/dist/SchemaConverterError.d.ts.map +0 -1
- package/dist/SchemaConverterError.js +0 -84
- package/dist/SchemaConverterError.js.map +0 -1
- package/dist/ast/BlockNode.d.ts +0 -453
- package/dist/ast/BlockNode.d.ts.map +0 -1
- package/dist/ast/BlockNode.js +0 -310
- package/dist/ast/BlockNode.js.map +0 -1
- package/dist/ast/Document.d.ts +0 -216
- package/dist/ast/Document.d.ts.map +0 -1
- package/dist/ast/Document.js +0 -69
- package/dist/ast/Document.js.map +0 -1
- package/dist/ast/InlineNode.d.ts +0 -477
- package/dist/ast/InlineNode.d.ts.map +0 -1
- package/dist/ast/InlineNode.js +0 -263
- package/dist/ast/InlineNode.js.map +0 -1
- package/dist/ast/MacroNode.d.ts +0 -267
- package/dist/ast/MacroNode.d.ts.map +0 -1
- package/dist/ast/MacroNode.js +0 -164
- package/dist/ast/MacroNode.js.map +0 -1
- package/dist/ast/index.d.ts +0 -10
- package/dist/ast/index.d.ts.map +0 -1
- package/dist/ast/index.js +0 -14
- package/dist/ast/index.js.map +0 -1
- package/dist/parsers/ConfluenceParser.d.ts +0 -26
- package/dist/parsers/ConfluenceParser.d.ts.map +0 -1
- package/dist/parsers/ConfluenceParser.js +0 -797
- package/dist/parsers/ConfluenceParser.js.map +0 -1
- package/dist/parsers/MarkdownParser.d.ts +0 -26
- package/dist/parsers/MarkdownParser.d.ts.map +0 -1
- package/dist/parsers/MarkdownParser.js +0 -982
- package/dist/parsers/MarkdownParser.js.map +0 -1
- package/dist/parsers/index.d.ts +0 -8
- package/dist/parsers/index.d.ts.map +0 -1
- package/dist/parsers/index.js +0 -8
- package/dist/parsers/index.js.map +0 -1
- package/dist/schemas/ConfluenceSchema.d.ts +0 -21
- package/dist/schemas/ConfluenceSchema.d.ts.map +0 -1
- package/dist/schemas/ConfluenceSchema.js +0 -38
- package/dist/schemas/ConfluenceSchema.js.map +0 -1
- package/dist/schemas/ConversionSchema.d.ts +0 -35
- package/dist/schemas/ConversionSchema.d.ts.map +0 -1
- package/dist/schemas/ConversionSchema.js +0 -208
- package/dist/schemas/ConversionSchema.js.map +0 -1
- package/dist/schemas/MarkdownSchema.d.ts +0 -21
- package/dist/schemas/MarkdownSchema.d.ts.map +0 -1
- package/dist/schemas/MarkdownSchema.js +0 -38
- package/dist/schemas/MarkdownSchema.js.map +0 -1
- package/dist/schemas/hast/HastFromHtml.d.ts +0 -27
- package/dist/schemas/hast/HastFromHtml.d.ts.map +0 -1
- package/dist/schemas/hast/HastFromHtml.js +0 -107
- package/dist/schemas/hast/HastFromHtml.js.map +0 -1
- package/dist/schemas/hast/HastSchema.d.ts +0 -195
- package/dist/schemas/hast/HastSchema.d.ts.map +0 -1
- package/dist/schemas/hast/HastSchema.js +0 -183
- package/dist/schemas/hast/HastSchema.js.map +0 -1
- package/dist/schemas/hast/index.d.ts +0 -9
- package/dist/schemas/hast/index.d.ts.map +0 -1
- package/dist/schemas/hast/index.js +0 -3
- package/dist/schemas/hast/index.js.map +0 -1
- package/dist/schemas/index.d.ts +0 -14
- package/dist/schemas/index.d.ts.map +0 -1
- package/dist/schemas/index.js +0 -16
- package/dist/schemas/index.js.map +0 -1
- package/dist/schemas/mdast/MdastFromMarkdown.d.ts +0 -30
- package/dist/schemas/mdast/MdastFromMarkdown.d.ts.map +0 -1
- package/dist/schemas/mdast/MdastFromMarkdown.js +0 -79
- package/dist/schemas/mdast/MdastFromMarkdown.js.map +0 -1
- package/dist/schemas/mdast/MdastSchema.d.ts +0 -385
- package/dist/schemas/mdast/MdastSchema.d.ts.map +0 -1
- package/dist/schemas/mdast/MdastSchema.js +0 -266
- package/dist/schemas/mdast/MdastSchema.js.map +0 -1
- package/dist/schemas/mdast/index.d.ts +0 -10
- package/dist/schemas/mdast/index.d.ts.map +0 -1
- package/dist/schemas/mdast/index.js +0 -4
- package/dist/schemas/mdast/index.js.map +0 -1
- package/dist/schemas/mdast/mdastToString.d.ts +0 -13
- package/dist/schemas/mdast/mdastToString.d.ts.map +0 -1
- package/dist/schemas/mdast/mdastToString.js +0 -85
- package/dist/schemas/mdast/mdastToString.js.map +0 -1
- package/dist/schemas/nodes/block/BlockSchema.d.ts +0 -43
- package/dist/schemas/nodes/block/BlockSchema.d.ts.map +0 -1
- package/dist/schemas/nodes/block/BlockSchema.js +0 -634
- package/dist/schemas/nodes/block/BlockSchema.js.map +0 -1
- package/dist/schemas/nodes/block/index.d.ts +0 -7
- package/dist/schemas/nodes/block/index.d.ts.map +0 -1
- package/dist/schemas/nodes/block/index.js +0 -7
- package/dist/schemas/nodes/block/index.js.map +0 -1
- package/dist/schemas/nodes/index.d.ts +0 -9
- package/dist/schemas/nodes/index.d.ts.map +0 -1
- package/dist/schemas/nodes/index.js +0 -12
- package/dist/schemas/nodes/index.js.map +0 -1
- package/dist/schemas/nodes/inline/InlineSchema.d.ts +0 -48
- package/dist/schemas/nodes/inline/InlineSchema.d.ts.map +0 -1
- package/dist/schemas/nodes/inline/InlineSchema.js +0 -436
- package/dist/schemas/nodes/inline/InlineSchema.js.map +0 -1
- package/dist/schemas/nodes/inline/index.d.ts +0 -7
- package/dist/schemas/nodes/inline/index.d.ts.map +0 -1
- package/dist/schemas/nodes/inline/index.js +0 -7
- package/dist/schemas/nodes/inline/index.js.map +0 -1
- package/dist/schemas/nodes/macro/MacroSchema.d.ts +0 -27
- package/dist/schemas/nodes/macro/MacroSchema.d.ts.map +0 -1
- package/dist/schemas/nodes/macro/MacroSchema.js +0 -162
- package/dist/schemas/nodes/macro/MacroSchema.js.map +0 -1
- package/dist/schemas/nodes/macro/index.d.ts +0 -7
- package/dist/schemas/nodes/macro/index.d.ts.map +0 -1
- package/dist/schemas/nodes/macro/index.js +0 -7
- package/dist/schemas/nodes/macro/index.js.map +0 -1
- package/dist/schemas/preprocessing/ConfluencePreprocessor.d.ts +0 -24
- package/dist/schemas/preprocessing/ConfluencePreprocessor.d.ts.map +0 -1
- package/dist/schemas/preprocessing/ConfluencePreprocessor.js +0 -359
- package/dist/schemas/preprocessing/ConfluencePreprocessor.js.map +0 -1
- package/dist/schemas/preprocessing/index.d.ts +0 -8
- package/dist/schemas/preprocessing/index.d.ts.map +0 -1
- package/dist/schemas/preprocessing/index.js +0 -2
- package/dist/schemas/preprocessing/index.js.map +0 -1
- package/dist/serializers/ConfluenceSerializer.d.ts +0 -30
- package/dist/serializers/ConfluenceSerializer.d.ts.map +0 -1
- package/dist/serializers/ConfluenceSerializer.js +0 -560
- package/dist/serializers/ConfluenceSerializer.js.map +0 -1
- package/dist/serializers/MarkdownSerializer.d.ts +0 -34
- package/dist/serializers/MarkdownSerializer.d.ts.map +0 -1
- package/dist/serializers/MarkdownSerializer.js +0 -395
- package/dist/serializers/MarkdownSerializer.js.map +0 -1
- package/dist/serializers/index.d.ts +0 -8
- package/dist/serializers/index.d.ts.map +0 -1
- package/dist/serializers/index.js +0 -8
- package/dist/serializers/index.js.map +0 -1
- package/src/SchemaConverterError.ts +0 -108
- package/src/ast/BlockNode.ts +0 -469
- package/src/ast/Document.ts +0 -90
- package/src/ast/InlineNode.ts +0 -323
- package/src/ast/MacroNode.ts +0 -245
- package/src/ast/index.ts +0 -83
- package/src/parsers/ConfluenceParser.ts +0 -956
- package/src/parsers/MarkdownParser.ts +0 -1338
- package/src/parsers/index.ts +0 -8
- package/src/schemas/ConfluenceSchema.ts +0 -56
- package/src/schemas/ConversionSchema.ts +0 -318
- package/src/schemas/MarkdownSchema.ts +0 -56
- package/src/schemas/hast/HastFromHtml.ts +0 -153
- package/src/schemas/hast/HastSchema.ts +0 -274
- package/src/schemas/hast/index.ts +0 -35
- package/src/schemas/index.ts +0 -20
- package/src/schemas/mdast/MdastFromMarkdown.ts +0 -118
- package/src/schemas/mdast/MdastSchema.ts +0 -566
- package/src/schemas/mdast/index.ts +0 -59
- package/src/schemas/mdast/mdastToString.ts +0 -102
- package/src/schemas/nodes/block/BlockSchema.ts +0 -773
- package/src/schemas/nodes/block/index.ts +0 -13
- package/src/schemas/nodes/index.ts +0 -20
- package/src/schemas/nodes/inline/InlineSchema.ts +0 -523
- package/src/schemas/nodes/inline/index.ts +0 -14
- package/src/schemas/nodes/macro/MacroSchema.ts +0 -226
- package/src/schemas/nodes/macro/index.ts +0 -6
- package/src/schemas/preprocessing/ConfluencePreprocessor.ts +0 -455
- package/src/schemas/preprocessing/index.ts +0 -8
- package/src/serializers/ConfluenceSerializer.ts +0 -737
- package/src/serializers/MarkdownSerializer.ts +0 -543
- package/src/serializers/index.ts +0 -8
- package/test/ast/BlockNode.test.ts +0 -265
- package/test/ast/Document.test.ts +0 -126
- package/test/ast/InlineNode.test.ts +0 -161
- package/test/fixtures/integration-test.html.fixture +0 -103
- package/test/fixtures/integration-test.md.expected +0 -257
- package/test/parsers/ConfluenceParser.test.ts +0 -452
- package/test/schemas/ConfluencePreprocessor.test.ts +0 -180
- package/test/schemas/ConversionSchema.test.ts +0 -159
- package/test/schemas/HastSchema.test.ts +0 -138
- package/test/schemas/MdastSchema.test.ts +0 -145
- package/test/schemas/nodes/block/BlockSchema.test.ts +0 -173
- package/test/schemas/nodes/inline/InlineSchema.test.ts +0 -198
- package/test/schemas/nodes/macro/MacroSchema.test.ts +0 -142
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
+
import * as Effect from "effect/Effect"
|
|
3
|
+
import { AtlaskitTransformers, layer as AtlaskitTransformersLayer } from "../src/AtlaskitTransformers.js"
|
|
4
|
+
|
|
5
|
+
describe("AtlaskitTransformers", () => {
|
|
6
|
+
it.effect("encodes markdown to ADF JSON", () =>
|
|
7
|
+
Effect.gen(function*() {
|
|
8
|
+
const t = yield* AtlaskitTransformers
|
|
9
|
+
const adf = yield* t.use(({ json, md }) => json.encode(md.parse("# Hello")))
|
|
10
|
+
expect(adf.type).toBe("doc")
|
|
11
|
+
expect(adf.content[0]?.type).toBe("heading")
|
|
12
|
+
}).pipe(Effect.provide(AtlaskitTransformersLayer)))
|
|
13
|
+
|
|
14
|
+
it.effect("surfaces synchronous throws as AtlaskitTransformersError", () =>
|
|
15
|
+
Effect.gen(function*() {
|
|
16
|
+
const t = yield* AtlaskitTransformers
|
|
17
|
+
const result = yield* Effect.result(t.use(() => {
|
|
18
|
+
throw new Error("boom")
|
|
19
|
+
}))
|
|
20
|
+
expect(result._tag).toBe("Failure")
|
|
21
|
+
if (result._tag === "Failure") {
|
|
22
|
+
expect(result.failure._tag).toBe("AtlaskitTransformersError")
|
|
23
|
+
}
|
|
24
|
+
}).pipe(Effect.provide(AtlaskitTransformersLayer)))
|
|
25
|
+
})
|
package/test/Brand.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
-
import * as
|
|
2
|
+
import * as Result from "effect/Result"
|
|
3
3
|
import * as Schema from "effect/Schema"
|
|
4
4
|
import { ContentHash, PageId, PageIdSchema, SpaceKey, SpaceKeySchema } from "../src/Brand.js"
|
|
5
5
|
|
|
@@ -17,13 +17,13 @@ describe("Brand", () => {
|
|
|
17
17
|
|
|
18
18
|
describe("PageIdSchema", () => {
|
|
19
19
|
it("decodes valid page IDs", () => {
|
|
20
|
-
const result = Schema.
|
|
21
|
-
expect(
|
|
20
|
+
const result = Schema.decodeUnknownResult(PageIdSchema)("123456")
|
|
21
|
+
expect(Result.isSuccess(result)).toBe(true)
|
|
22
22
|
})
|
|
23
23
|
|
|
24
24
|
it("rejects empty strings", () => {
|
|
25
|
-
const result = Schema.
|
|
26
|
-
expect(
|
|
25
|
+
const result = Schema.decodeUnknownResult(PageIdSchema)("")
|
|
26
|
+
expect(Result.isFailure(result)).toBe(true)
|
|
27
27
|
})
|
|
28
28
|
})
|
|
29
29
|
|
|
@@ -40,18 +40,18 @@ describe("Brand", () => {
|
|
|
40
40
|
|
|
41
41
|
describe("SpaceKeySchema", () => {
|
|
42
42
|
it("decodes uppercase alphanumeric keys", () => {
|
|
43
|
-
const result = Schema.
|
|
44
|
-
expect(
|
|
43
|
+
const result = Schema.decodeUnknownResult(SpaceKeySchema)("MYSPACE123")
|
|
44
|
+
expect(Result.isSuccess(result)).toBe(true)
|
|
45
45
|
})
|
|
46
46
|
|
|
47
47
|
it("rejects lowercase keys", () => {
|
|
48
|
-
const result = Schema.
|
|
49
|
-
expect(
|
|
48
|
+
const result = Schema.decodeUnknownResult(SpaceKeySchema)("myspace")
|
|
49
|
+
expect(Result.isFailure(result)).toBe(true)
|
|
50
50
|
})
|
|
51
51
|
|
|
52
52
|
it("rejects keys with special characters", () => {
|
|
53
|
-
const result = Schema.
|
|
54
|
-
expect(
|
|
53
|
+
const result = Schema.decodeUnknownResult(SpaceKeySchema)("MY-SPACE")
|
|
54
|
+
expect(Result.isFailure(result)).toBe(true)
|
|
55
55
|
})
|
|
56
56
|
})
|
|
57
57
|
|
package/test/GitService.test.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { NodeServices } from "@effect/platform-node"
|
|
1
2
|
import { describe, expect, it } from "@effect/vitest"
|
|
2
3
|
import * as Effect from "effect/Effect"
|
|
4
|
+
import * as Layer from "effect/Layer"
|
|
3
5
|
import { GitService, layer as GitServiceLayer } from "../src/GitService.js"
|
|
4
6
|
import { getConflictedFiles, GIT_LOG_FORMAT, parseGitLog, parseGitStatus } from "../src/internal/gitCommands.js"
|
|
5
7
|
|
|
@@ -7,6 +9,8 @@ import { getConflictedFiles, GIT_LOG_FORMAT, parseGitLog, parseGitStatus } from
|
|
|
7
9
|
* Tests for git parsing utilities and GitService.
|
|
8
10
|
*/
|
|
9
11
|
describe("GitService", () => {
|
|
12
|
+
const TestLayer = Layer.provideMerge(GitServiceLayer, NodeServices.layer)
|
|
13
|
+
|
|
10
14
|
describe("parseGitStatus", () => {
|
|
11
15
|
it("parses empty status", () => {
|
|
12
16
|
const entries = parseGitStatus("")
|
|
@@ -197,13 +201,13 @@ M normal.ts`
|
|
|
197
201
|
const git = yield* GitService
|
|
198
202
|
const version = yield* git.validateGit()
|
|
199
203
|
expect(version).toContain("git version")
|
|
200
|
-
}).pipe(Effect.provide(
|
|
204
|
+
}).pipe(Effect.provide(TestLayer)))
|
|
201
205
|
|
|
202
206
|
it.effect("isInitialized returns boolean", () =>
|
|
203
207
|
Effect.gen(function*() {
|
|
204
208
|
const git = yield* GitService
|
|
205
209
|
const initialized = yield* git.isInitialized()
|
|
206
210
|
expect(typeof initialized).toBe("boolean")
|
|
207
|
-
}).pipe(Effect.provide(
|
|
211
|
+
}).pipe(Effect.provide(TestLayer)))
|
|
208
212
|
})
|
|
209
213
|
})
|
|
@@ -1,142 +1,158 @@
|
|
|
1
1
|
import { describe, expect, it } from "@effect/vitest"
|
|
2
2
|
import * as Effect from "effect/Effect"
|
|
3
|
-
import
|
|
3
|
+
import * as Layer from "effect/Layer"
|
|
4
|
+
import { layer as AdfSchemaValidatorLayer } from "../src/AdfSchemaValidator.js"
|
|
5
|
+
import { layer as AtlaskitTransformersLayer } from "../src/AtlaskitTransformers.js"
|
|
6
|
+
import { layer as MarkdownConverterLayer, MarkdownConverter } from "../src/MarkdownConverter.js"
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const converter = yield* MarkdownConverter
|
|
10
|
-
const html = "<p>Hello <strong>world</strong></p>"
|
|
11
|
-
const markdown = yield* converter.htmlToMarkdown(html)
|
|
12
|
-
expect(markdown).toContain("Hello")
|
|
13
|
-
expect(markdown).toContain("**world**")
|
|
14
|
-
}).pipe(Effect.provide(MarkdownConverterLayer)))
|
|
8
|
+
const TestLayer = MarkdownConverterLayer.pipe(
|
|
9
|
+
Layer.provide(AtlaskitTransformersLayer),
|
|
10
|
+
Layer.provide(AdfSchemaValidatorLayer)
|
|
11
|
+
)
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
Effect.gen(function*() {
|
|
18
|
-
const converter = yield* MarkdownConverter
|
|
19
|
-
const html = "<h1>Title</h1><h2>Subtitle</h2>"
|
|
20
|
-
const markdown = yield* converter.htmlToMarkdown(html)
|
|
21
|
-
expect(markdown).toContain("# Title")
|
|
22
|
-
expect(markdown).toContain("## Subtitle")
|
|
23
|
-
}).pipe(Effect.provide(MarkdownConverterLayer)))
|
|
13
|
+
const minimalDoc = (content: ReadonlyArray<unknown>): string => JSON.stringify({ version: 1, type: "doc", content })
|
|
24
14
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const html = "<ul><li>Item 1</li><li>Item 2</li></ul>"
|
|
29
|
-
const markdown = yield* converter.htmlToMarkdown(html)
|
|
30
|
-
// AST-based serializer uses - for unordered lists
|
|
31
|
-
expect(markdown).toContain("- Item 1")
|
|
32
|
-
expect(markdown).toContain("- Item 2")
|
|
33
|
-
}).pipe(Effect.provide(MarkdownConverterLayer)))
|
|
34
|
-
|
|
35
|
-
it.effect("converts links", () =>
|
|
15
|
+
describe("MarkdownConverter", () => {
|
|
16
|
+
describe("adfToMarkdown", () => {
|
|
17
|
+
it.effect("converts a heading", () =>
|
|
36
18
|
Effect.gen(function*() {
|
|
37
19
|
const converter = yield* MarkdownConverter
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
20
|
+
const md = yield* converter.adfToMarkdown(
|
|
21
|
+
minimalDoc([{ type: "heading", attrs: { level: 1 }, content: [{ type: "text", text: "Hello" }] }])
|
|
22
|
+
)
|
|
23
|
+
expect(md).toContain("# Hello")
|
|
24
|
+
}).pipe(Effect.provide(TestLayer)))
|
|
42
25
|
|
|
43
|
-
it.effect("converts
|
|
26
|
+
it.effect("converts a paragraph with marks", () =>
|
|
44
27
|
Effect.gen(function*() {
|
|
45
28
|
const converter = yield* MarkdownConverter
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
29
|
+
const md = yield* converter.adfToMarkdown(
|
|
30
|
+
minimalDoc([{
|
|
31
|
+
type: "paragraph",
|
|
32
|
+
content: [
|
|
33
|
+
{ type: "text", text: "Hello " },
|
|
34
|
+
{ type: "text", text: "world", marks: [{ type: "strong" }] }
|
|
35
|
+
]
|
|
36
|
+
}])
|
|
37
|
+
)
|
|
38
|
+
expect(md).toContain("Hello")
|
|
39
|
+
expect(md).toContain("**world**")
|
|
40
|
+
}).pipe(Effect.provide(TestLayer)))
|
|
51
41
|
|
|
52
|
-
it.effect("
|
|
42
|
+
it.effect("converts a bullet list", () =>
|
|
53
43
|
Effect.gen(function*() {
|
|
54
44
|
const converter = yield* MarkdownConverter
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
45
|
+
const md = yield* converter.adfToMarkdown(
|
|
46
|
+
minimalDoc([{
|
|
47
|
+
type: "bulletList",
|
|
48
|
+
content: [
|
|
49
|
+
{
|
|
50
|
+
type: "listItem",
|
|
51
|
+
content: [{ type: "paragraph", content: [{ type: "text", text: "one" }] }]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
type: "listItem",
|
|
55
|
+
content: [{ type: "paragraph", content: [{ type: "text", text: "two" }] }]
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}])
|
|
59
|
+
)
|
|
60
|
+
expect(md).toContain("- one")
|
|
61
|
+
expect(md).toContain("- two")
|
|
62
|
+
}).pipe(Effect.provide(TestLayer)))
|
|
61
63
|
|
|
62
|
-
it.effect("converts
|
|
64
|
+
it.effect("converts a code block with language", () =>
|
|
63
65
|
Effect.gen(function*() {
|
|
64
66
|
const converter = yield* MarkdownConverter
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
const md = yield* converter.adfToMarkdown(
|
|
68
|
+
minimalDoc([{
|
|
69
|
+
type: "codeBlock",
|
|
70
|
+
attrs: { language: "ts" },
|
|
71
|
+
content: [{ type: "text", text: "const x = 1" }]
|
|
72
|
+
}])
|
|
73
|
+
)
|
|
74
|
+
expect(md).toContain("```ts")
|
|
75
|
+
expect(md).toContain("const x = 1")
|
|
76
|
+
}).pipe(Effect.provide(TestLayer)))
|
|
72
77
|
|
|
73
|
-
|
|
74
|
-
it.effect("converts basic markdown to HTML", () =>
|
|
78
|
+
it.effect("converts a panel to a Confluence-preserving placeholder", () =>
|
|
75
79
|
Effect.gen(function*() {
|
|
76
80
|
const converter = yield* MarkdownConverter
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
const md = yield* converter.adfToMarkdown(
|
|
82
|
+
minimalDoc([{
|
|
83
|
+
type: "panel",
|
|
84
|
+
attrs: { panelType: "info" },
|
|
85
|
+
content: [{ type: "paragraph", content: [{ type: "text", text: "heads up" }] }]
|
|
86
|
+
}])
|
|
87
|
+
)
|
|
88
|
+
expect(md).toContain("<!-- adf:panel type=info attrs=")
|
|
89
|
+
expect(md).toContain("heads up")
|
|
90
|
+
expect(md).toContain("<!-- adf:/panel -->")
|
|
91
|
+
}).pipe(Effect.provide(TestLayer)))
|
|
81
92
|
|
|
82
|
-
it.effect("
|
|
93
|
+
it.effect("fails with ConversionError on invalid JSON", () =>
|
|
83
94
|
Effect.gen(function*() {
|
|
84
95
|
const converter = yield* MarkdownConverter
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
96
|
+
const result = yield* Effect.result(converter.adfToMarkdown("not json"))
|
|
97
|
+
expect(result._tag).toBe("Failure")
|
|
98
|
+
if (result._tag === "Failure") {
|
|
99
|
+
expect(result.failure._tag).toBe("ConversionError")
|
|
100
|
+
expect(result.failure.direction).toBe("adfToMarkdown")
|
|
101
|
+
}
|
|
102
|
+
}).pipe(Effect.provide(TestLayer)))
|
|
90
103
|
|
|
91
|
-
it.effect("
|
|
104
|
+
it.effect("treats schema-invalid incoming ADF as advisory and still converts", () =>
|
|
92
105
|
Effect.gen(function*() {
|
|
93
106
|
const converter = yield* MarkdownConverter
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
107
|
+
// Missing `version`, and `attrs.level` should be a number — both are
|
|
108
|
+
// schema violations Confluence would never produce, but representative
|
|
109
|
+
// of the schema drift we tolerate on the incoming side.
|
|
110
|
+
const md = yield* converter.adfToMarkdown(JSON.stringify({
|
|
111
|
+
type: "doc",
|
|
112
|
+
content: [{
|
|
113
|
+
type: "heading",
|
|
114
|
+
attrs: { level: "1" },
|
|
115
|
+
content: [{ type: "text", text: "Hello" }]
|
|
116
|
+
}]
|
|
117
|
+
}))
|
|
118
|
+
expect(md).toContain("Hello")
|
|
119
|
+
}).pipe(Effect.provide(TestLayer)))
|
|
100
120
|
|
|
101
|
-
it.effect("
|
|
121
|
+
it.effect("still fails on input too malformed to walk", () =>
|
|
102
122
|
Effect.gen(function*() {
|
|
123
|
+
// Advisory validation tolerates schema drift, not non-documents:
|
|
124
|
+
// walking `null` is a defect, `{}`/arrays silently produce an empty
|
|
125
|
+
// page that could overwrite a real local file.
|
|
103
126
|
const converter = yield* MarkdownConverter
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
127
|
+
for (const bad of ["null", "{}", "[1,2]", `{"type":"doc","content":"not an array"}`]) {
|
|
128
|
+
const result = yield* Effect.result(converter.adfToMarkdown(bad))
|
|
129
|
+
expect(result._tag).toBe("Failure")
|
|
130
|
+
if (result._tag === "Failure") {
|
|
131
|
+
expect(result.failure._tag).toBe("ConversionError")
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}).pipe(Effect.provide(TestLayer)))
|
|
108
135
|
})
|
|
109
136
|
|
|
110
|
-
describe("
|
|
111
|
-
it.effect("
|
|
112
|
-
Effect.gen(function*() {
|
|
113
|
-
const converter = yield* MarkdownConverter
|
|
114
|
-
const html = "<h1>Title</h1><p>Hello world</p>"
|
|
115
|
-
const markdown = yield* converter.htmlToMarkdown(html)
|
|
116
|
-
expect(markdown).toContain("# Title")
|
|
117
|
-
expect(markdown).toContain("Hello world")
|
|
118
|
-
}).pipe(Effect.provide(schemaBasedLayer)))
|
|
119
|
-
|
|
120
|
-
it.effect("htmlToAst parses HTML to Document", () =>
|
|
137
|
+
describe("markdownToAdf", () => {
|
|
138
|
+
it.effect("produces a valid ADF doc for a heading", () =>
|
|
121
139
|
Effect.gen(function*() {
|
|
122
140
|
const converter = yield* MarkdownConverter
|
|
123
|
-
const
|
|
124
|
-
const
|
|
125
|
-
expect(
|
|
126
|
-
expect(
|
|
127
|
-
expect(
|
|
128
|
-
|
|
129
|
-
}).pipe(Effect.provide(schemaBasedLayer)))
|
|
141
|
+
const adf = yield* converter.markdownToAdf("# Title\n\nBody")
|
|
142
|
+
const parsed = JSON.parse(adf) as { type: string; version: number; content: ReadonlyArray<{ type: string }> }
|
|
143
|
+
expect(parsed.type).toBe("doc")
|
|
144
|
+
expect(parsed.version).toBe(1)
|
|
145
|
+
expect(parsed.content[0]?.type).toBe("heading")
|
|
146
|
+
}).pipe(Effect.provide(TestLayer)))
|
|
130
147
|
|
|
131
|
-
it.effect("
|
|
148
|
+
it.effect("round-trips a heading + paragraph through both directions", () =>
|
|
132
149
|
Effect.gen(function*() {
|
|
133
150
|
const converter = yield* MarkdownConverter
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
expect(
|
|
138
|
-
expect(
|
|
139
|
-
|
|
140
|
-
}).pipe(Effect.provide(schemaBasedLayer)))
|
|
151
|
+
const md1 = "# Title\n\nHello **world**"
|
|
152
|
+
const adf = yield* converter.markdownToAdf(md1)
|
|
153
|
+
const md2 = yield* converter.adfToMarkdown(adf)
|
|
154
|
+
expect(md2).toContain("# Title")
|
|
155
|
+
expect(md2).toContain("**world**")
|
|
156
|
+
}).pipe(Effect.provide(TestLayer)))
|
|
141
157
|
})
|
|
142
158
|
})
|