@knpkv/confluence-to-markdown 0.6.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 +39 -0
- package/LICENSE +21 -0
- package/README.md +22 -13
- 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 +37 -39
- package/dist/ConfluenceAuth.js.map +1 -1
- package/dist/ConfluenceClient.d.ts +7 -17
- package/dist/ConfluenceClient.d.ts.map +1 -1
- package/dist/ConfluenceClient.js +81 -38
- 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 +68 -16
- package/dist/ConfluenceError.d.ts.map +1 -1
- package/dist/ConfluenceError.js +30 -1
- package/dist/ConfluenceError.js.map +1 -1
- package/dist/GitError.d.ts +5 -5
- package/dist/GitService.d.ts +11 -3
- package/dist/GitService.d.ts.map +1 -1
- package/dist/GitService.js +22 -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 +30 -30
- package/skills/confluence/SKILL.md +143 -0
- package/skills/confluence/agents/openai.yaml +4 -0
- package/src/AdfPlaceholders.ts +310 -13
- package/src/AdfSchemaValidator.ts +2 -4
- package/src/AdfWalker.ts +122 -42
- package/src/AtlaskitTransformers.ts +2 -4
- package/src/Brand.ts +11 -16
- package/src/ConfluenceAuth.ts +22 -30
- package/src/ConfluenceClient.ts +24 -20
- package/src/ConfluenceConfig.ts +14 -14
- package/src/GitService.ts +39 -49
- package/src/LocalFileSystem.ts +7 -9
- package/src/MarkdownConverter.ts +2 -4
- package/src/Schemas.ts +13 -12
- package/src/SyncEngine.ts +151 -53
- package/src/bin.ts +30 -56
- package/src/commands/auth.ts +21 -18
- package/src/commands/clone.ts +38 -37
- 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 +53 -33
- 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/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 +213 -0
- package/test/AdfSchemaValidator.test.ts +6 -6
- package/test/AdfWalker.test.ts +167 -21
- package/test/AtlaskitTransformers.test.ts +4 -4
- package/test/Brand.test.ts +11 -11
- package/test/GitService.test.ts +6 -2
- package/test/MarkdownConverter.test.ts +12 -11
- package/test/RoundTrip.test.ts +258 -3
- 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 -468
- package/dist/ast/BlockNode.d.ts.map +0 -1
- package/dist/ast/BlockNode.js +0 -319
- package/dist/ast/BlockNode.js.map +0 -1
- package/dist/ast/Document.d.ts +0 -244
- 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 -792
- 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 -873
- 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/parsers/preprocessing/ConfluencePreprocessing.d.ts +0 -23
- package/dist/parsers/preprocessing/ConfluencePreprocessing.d.ts.map +0 -1
- package/dist/parsers/preprocessing/ConfluencePreprocessing.js +0 -323
- package/dist/parsers/preprocessing/ConfluencePreprocessing.js.map +0 -1
- package/dist/parsers/preprocessing/index.d.ts +0 -7
- package/dist/parsers/preprocessing/index.d.ts.map +0 -1
- package/dist/parsers/preprocessing/index.js +0 -7
- package/dist/parsers/preprocessing/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 -53
- package/dist/schemas/preprocessing/ConfluencePreprocessor.d.ts.map +0 -1
- package/dist/schemas/preprocessing/ConfluencePreprocessor.js +0 -349
- 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 -551
- 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 -355
- 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
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
+
import { getLayerType } from "../src/commands/layers.js"
|
|
3
|
+
|
|
4
|
+
describe("getLayerType", () => {
|
|
5
|
+
it("routes fetch to the config-free fetch layer", () => {
|
|
6
|
+
expect(getLayerType(["fetch"])).toBe("fetch")
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
it("keeps clone on the clone layer", () => {
|
|
10
|
+
expect(getLayerType(["clone"])).toBe("clone")
|
|
11
|
+
})
|
|
12
|
+
})
|
package/test/oauthServer.test.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
|
|
2
|
-
import * as HttpClient from "@effect/platform/HttpClient"
|
|
3
|
-
import * as HttpClientRequest from "@effect/platform/HttpClientRequest"
|
|
4
2
|
import { describe, expect, it } from "@effect/vitest"
|
|
5
3
|
import * as Effect from "effect/Effect"
|
|
6
4
|
import * as Fiber from "effect/Fiber"
|
|
7
5
|
import * as Layer from "effect/Layer"
|
|
6
|
+
import { HttpClient, HttpClientRequest } from "effect/unstable/http"
|
|
8
7
|
import { HttpServerFactoryLive } from "../src/internal/NodeLayers.js"
|
|
9
8
|
import { startCallbackServer } from "../src/internal/oauthServer.js"
|
|
10
9
|
|
|
11
|
-
const HttpClientLive = NodeHttpClient.
|
|
10
|
+
const HttpClientLive = NodeHttpClient.layerUndici
|
|
12
11
|
|
|
13
12
|
describe("oauthServer", () => {
|
|
14
13
|
describe("startCallbackServer", () => {
|
|
@@ -17,7 +16,7 @@ describe("oauthServer", () => {
|
|
|
17
16
|
const expectedState = "test-state-123"
|
|
18
17
|
const result = yield* startCallbackServer(expectedState)
|
|
19
18
|
|
|
20
|
-
expect(result.port).
|
|
19
|
+
expect(result.port).toBe(8585)
|
|
21
20
|
expect(typeof result.codePromise).toBe("object")
|
|
22
21
|
expect(typeof result.shutdown).toBe("object")
|
|
23
22
|
|
|
@@ -31,7 +30,7 @@ describe("oauthServer", () => {
|
|
|
31
30
|
const { codePromise, port, shutdown } = yield* startCallbackServer(expectedState)
|
|
32
31
|
|
|
33
32
|
// Make callback request in background
|
|
34
|
-
const codeReceiver = yield* Effect.
|
|
33
|
+
const codeReceiver = yield* Effect.forkChild(codePromise)
|
|
35
34
|
|
|
36
35
|
// Simulate OAuth callback using Effect HttpClient
|
|
37
36
|
const client = yield* HttpClient.HttpClient
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
+
import * as Effect from "effect/Effect"
|
|
3
|
+
import { parseConfluencePageUrl, resolvePageInput } from "../src/commands/pageInput.js"
|
|
4
|
+
|
|
5
|
+
describe("page input", () => {
|
|
6
|
+
it.effect("parses shorthand Atlassian URLs", () =>
|
|
7
|
+
Effect.gen(function*() {
|
|
8
|
+
const result = yield* parseConfluencePageUrl("https://example.atlassian.com/2333334354")
|
|
9
|
+
|
|
10
|
+
expect(result).toEqual({
|
|
11
|
+
baseUrl: "https://example.atlassian.com",
|
|
12
|
+
pageId: "2333334354"
|
|
13
|
+
})
|
|
14
|
+
}))
|
|
15
|
+
|
|
16
|
+
it.effect("parses space page URLs", () =>
|
|
17
|
+
Effect.gen(function*() {
|
|
18
|
+
const result = yield* parseConfluencePageUrl(
|
|
19
|
+
"https://example.atlassian.net/wiki/spaces/DEV/pages/2333334354/Page+Title"
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
expect(result).toEqual({
|
|
23
|
+
baseUrl: "https://example.atlassian.net",
|
|
24
|
+
pageId: "2333334354"
|
|
25
|
+
})
|
|
26
|
+
}))
|
|
27
|
+
|
|
28
|
+
it.effect("parses wiki page URLs", () =>
|
|
29
|
+
Effect.gen(function*() {
|
|
30
|
+
const result = yield* parseConfluencePageUrl("https://example.atlassian.net/wiki/pages/2333334354")
|
|
31
|
+
|
|
32
|
+
expect(result).toEqual({
|
|
33
|
+
baseUrl: "https://example.atlassian.net",
|
|
34
|
+
pageId: "2333334354"
|
|
35
|
+
})
|
|
36
|
+
}))
|
|
37
|
+
|
|
38
|
+
it.effect("rejects unsupported hosts", () =>
|
|
39
|
+
Effect.gen(function*() {
|
|
40
|
+
const result = yield* Effect.result(parseConfluencePageUrl("https://example.com/wiki/pages/2333334354"))
|
|
41
|
+
|
|
42
|
+
expect(result._tag).toBe("Failure")
|
|
43
|
+
}))
|
|
44
|
+
|
|
45
|
+
it.effect("rejects URLs without a page ID", () =>
|
|
46
|
+
Effect.gen(function*() {
|
|
47
|
+
const result = yield* Effect.result(parseConfluencePageUrl("https://example.atlassian.net/wiki/spaces/DEV"))
|
|
48
|
+
|
|
49
|
+
expect(result._tag).toBe("Failure")
|
|
50
|
+
}))
|
|
51
|
+
|
|
52
|
+
it.effect("rejects page URLs when the segment after pages is not numeric", () =>
|
|
53
|
+
Effect.gen(function*() {
|
|
54
|
+
const result = yield* Effect.result(
|
|
55
|
+
parseConfluencePageUrl("https://example.atlassian.net/wiki/spaces/DEV/pages/not-a-page-id/2333334354")
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
expect(result._tag).toBe("Failure")
|
|
59
|
+
}))
|
|
60
|
+
|
|
61
|
+
it.effect("resolves separate page ID and base URL", () =>
|
|
62
|
+
Effect.gen(function*() {
|
|
63
|
+
const result = yield* resolvePageInput({
|
|
64
|
+
pageId: "2333334354",
|
|
65
|
+
baseUrl: "https://example.atlassian.net"
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
expect(result).toEqual({
|
|
69
|
+
baseUrl: "https://example.atlassian.net",
|
|
70
|
+
pageId: "2333334354"
|
|
71
|
+
})
|
|
72
|
+
}))
|
|
73
|
+
|
|
74
|
+
it.effect("rejects mixed URL and separate flags", () =>
|
|
75
|
+
Effect.gen(function*() {
|
|
76
|
+
const result = yield* Effect.result(resolvePageInput({
|
|
77
|
+
url: "https://example.atlassian.net/wiki/pages/2333334354",
|
|
78
|
+
pageId: "2333334354"
|
|
79
|
+
}))
|
|
80
|
+
|
|
81
|
+
expect(result._tag).toBe("Failure")
|
|
82
|
+
}))
|
|
83
|
+
})
|
|
@@ -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 { OAuthConfigSchema, OAuthTokenSchema } from "../src/Schemas.js"
|
|
5
5
|
|
|
@@ -18,8 +18,8 @@ describe("tokenStorage schemas", () => {
|
|
|
18
18
|
cloud_id: "test_cloud_id",
|
|
19
19
|
site_url: "https://test.atlassian.net"
|
|
20
20
|
}
|
|
21
|
-
const result = Schema.
|
|
22
|
-
expect(
|
|
21
|
+
const result = Schema.decodeUnknownResult(OAuthTokenSchema)(token)
|
|
22
|
+
expect(Result.isSuccess(result)).toBe(true)
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
it("validates token with user info", () => {
|
|
@@ -36,10 +36,10 @@ describe("tokenStorage schemas", () => {
|
|
|
36
36
|
email: "test@example.com"
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
const result = Schema.
|
|
40
|
-
expect(
|
|
41
|
-
if (
|
|
42
|
-
expect(result.
|
|
39
|
+
const result = Schema.decodeUnknownResult(OAuthTokenSchema)(token)
|
|
40
|
+
expect(Result.isSuccess(result)).toBe(true)
|
|
41
|
+
if (Result.isSuccess(result)) {
|
|
42
|
+
expect(result.success.user?.name).toBe("Test User")
|
|
43
43
|
}
|
|
44
44
|
})
|
|
45
45
|
|
|
@@ -52,8 +52,8 @@ describe("tokenStorage schemas", () => {
|
|
|
52
52
|
cloud_id: "test",
|
|
53
53
|
site_url: "https://test.atlassian.net"
|
|
54
54
|
}
|
|
55
|
-
const result = Schema.
|
|
56
|
-
expect(
|
|
55
|
+
const result = Schema.decodeUnknownResult(OAuthTokenSchema)(token)
|
|
56
|
+
expect(Result.isFailure(result)).toBe(true)
|
|
57
57
|
})
|
|
58
58
|
|
|
59
59
|
it("rejects token with invalid expires_at type", () => {
|
|
@@ -65,8 +65,8 @@ describe("tokenStorage schemas", () => {
|
|
|
65
65
|
cloud_id: "test",
|
|
66
66
|
site_url: "https://test.atlassian.net"
|
|
67
67
|
}
|
|
68
|
-
const result = Schema.
|
|
69
|
-
expect(
|
|
68
|
+
const result = Schema.decodeUnknownResult(OAuthTokenSchema)(token)
|
|
69
|
+
expect(Result.isFailure(result)).toBe(true)
|
|
70
70
|
})
|
|
71
71
|
})
|
|
72
72
|
|
|
@@ -76,24 +76,24 @@ describe("tokenStorage schemas", () => {
|
|
|
76
76
|
clientId: "test_client_id",
|
|
77
77
|
clientSecret: "test_client_secret"
|
|
78
78
|
}
|
|
79
|
-
const result = Schema.
|
|
80
|
-
expect(
|
|
79
|
+
const result = Schema.decodeUnknownResult(OAuthConfigSchema)(config)
|
|
80
|
+
expect(Result.isSuccess(result)).toBe(true)
|
|
81
81
|
})
|
|
82
82
|
|
|
83
83
|
it("rejects config missing clientSecret", () => {
|
|
84
84
|
const config = {
|
|
85
85
|
clientId: "test_client_id"
|
|
86
86
|
}
|
|
87
|
-
const result = Schema.
|
|
88
|
-
expect(
|
|
87
|
+
const result = Schema.decodeUnknownResult(OAuthConfigSchema)(config)
|
|
88
|
+
expect(Result.isFailure(result)).toBe(true)
|
|
89
89
|
})
|
|
90
90
|
|
|
91
91
|
it("rejects config missing clientId", () => {
|
|
92
92
|
const config = {
|
|
93
93
|
clientSecret: "test_client_secret"
|
|
94
94
|
}
|
|
95
|
-
const result = Schema.
|
|
96
|
-
expect(
|
|
95
|
+
const result = Schema.decodeUnknownResult(OAuthConfigSchema)(config)
|
|
96
|
+
expect(Result.isFailure(result)).toBe(true)
|
|
97
97
|
})
|
|
98
98
|
})
|
|
99
99
|
})
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
declare const ParseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
2
|
-
readonly _tag: "ParseError";
|
|
3
|
-
} & Readonly<A>;
|
|
4
|
-
/**
|
|
5
|
-
* Error thrown when parsing HTML or Markdown fails.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* import { Effect } from "effect"
|
|
10
|
-
* import { ParseError } from "@knpkv/confluence-to-markdown/SchemaConverterError"
|
|
11
|
-
*
|
|
12
|
-
* Effect.gen(function* () {
|
|
13
|
-
* // ... parsing operation
|
|
14
|
-
* }).pipe(
|
|
15
|
-
* Effect.catchTag("ParseError", (error) =>
|
|
16
|
-
* Effect.sync(() => console.error(`Parse error: ${error.message}`))
|
|
17
|
-
* )
|
|
18
|
-
* )
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* @category Errors
|
|
22
|
-
*/
|
|
23
|
-
export declare class ParseError extends ParseError_base<{
|
|
24
|
-
readonly source: "confluence" | "markdown";
|
|
25
|
-
readonly message: string;
|
|
26
|
-
readonly position?: {
|
|
27
|
-
readonly line: number;
|
|
28
|
-
readonly column: number;
|
|
29
|
-
};
|
|
30
|
-
readonly rawContent?: string;
|
|
31
|
-
}> {
|
|
32
|
-
}
|
|
33
|
-
declare const SerializeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
34
|
-
readonly _tag: "SerializeError";
|
|
35
|
-
} & Readonly<A>;
|
|
36
|
-
/**
|
|
37
|
-
* Error thrown when serializing AST to HTML or Markdown fails.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```typescript
|
|
41
|
-
* import { Effect } from "effect"
|
|
42
|
-
* import { SerializeError } from "@knpkv/confluence-to-markdown/SchemaConverterError"
|
|
43
|
-
*
|
|
44
|
-
* Effect.gen(function* () {
|
|
45
|
-
* // ... serialization operation
|
|
46
|
-
* }).pipe(
|
|
47
|
-
* Effect.catchTag("SerializeError", (error) =>
|
|
48
|
-
* Effect.sync(() => console.error(`Serialize error: ${error.message}`))
|
|
49
|
-
* )
|
|
50
|
-
* )
|
|
51
|
-
* ```
|
|
52
|
-
*
|
|
53
|
-
* @category Errors
|
|
54
|
-
*/
|
|
55
|
-
export declare class SerializeError extends SerializeError_base<{
|
|
56
|
-
readonly target: "confluence" | "markdown";
|
|
57
|
-
readonly nodeType: string;
|
|
58
|
-
readonly message: string;
|
|
59
|
-
}> {
|
|
60
|
-
}
|
|
61
|
-
declare const MigrationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
62
|
-
readonly _tag: "MigrationError";
|
|
63
|
-
} & Readonly<A>;
|
|
64
|
-
/**
|
|
65
|
-
* Error thrown when migrating between schema versions fails.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```typescript
|
|
69
|
-
* import { Effect } from "effect"
|
|
70
|
-
* import { MigrationError } from "@knpkv/confluence-to-markdown/SchemaConverterError"
|
|
71
|
-
*
|
|
72
|
-
* Effect.gen(function* () {
|
|
73
|
-
* // ... migration operation
|
|
74
|
-
* }).pipe(
|
|
75
|
-
* Effect.catchTag("MigrationError", (error) =>
|
|
76
|
-
* Effect.sync(() =>
|
|
77
|
-
* console.error(`Migration error: ${error.nodeType} v${error.fromVersion} -> v${error.toVersion}`)
|
|
78
|
-
* )
|
|
79
|
-
* )
|
|
80
|
-
* )
|
|
81
|
-
* ```
|
|
82
|
-
*
|
|
83
|
-
* @category Errors
|
|
84
|
-
*/
|
|
85
|
-
export declare class MigrationError extends MigrationError_base<{
|
|
86
|
-
readonly nodeType: string;
|
|
87
|
-
readonly fromVersion: number;
|
|
88
|
-
readonly toVersion: number;
|
|
89
|
-
readonly message: string;
|
|
90
|
-
}> {
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Union of all schema converter errors.
|
|
94
|
-
*
|
|
95
|
-
* @category Errors
|
|
96
|
-
*/
|
|
97
|
-
export type SchemaConverterError = ParseError | SerializeError | MigrationError;
|
|
98
|
-
/**
|
|
99
|
-
* Type guard to check if error is a SchemaConverterError.
|
|
100
|
-
*
|
|
101
|
-
* @param error - The error to check
|
|
102
|
-
* @returns True if error is a SchemaConverterError
|
|
103
|
-
*
|
|
104
|
-
* @category Utilities
|
|
105
|
-
*/
|
|
106
|
-
export declare const isSchemaConverterError: (error: unknown) => error is SchemaConverterError;
|
|
107
|
-
export {};
|
|
108
|
-
//# sourceMappingURL=SchemaConverterError.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaConverterError.d.ts","sourceRoot":"","sources":["../src/SchemaConverterError.ts"],"names":[],"mappings":";;;AAOA;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,UAAW,SAAQ,gBAA+B;IAC7D,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CAAA;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;IACtE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC7B,CAAC;CAAG;;;;AAEL;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,cAAe,SAAQ,oBAAmC;IACrE,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CAAA;IAC1C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAC;CAAG;;;;AAEL;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,cAAe,SAAQ,oBAAmC;IACrE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAC;CAAG;AAEL;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,cAAc,GAAG,cAAc,CAAA;AAE/E;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,oBAM9D,CAAA"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error types for schema-based conversion.
|
|
3
|
-
*
|
|
4
|
-
* @module
|
|
5
|
-
*/
|
|
6
|
-
import * as Data from "effect/Data";
|
|
7
|
-
/**
|
|
8
|
-
* Error thrown when parsing HTML or Markdown fails.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* import { Effect } from "effect"
|
|
13
|
-
* import { ParseError } from "@knpkv/confluence-to-markdown/SchemaConverterError"
|
|
14
|
-
*
|
|
15
|
-
* Effect.gen(function* () {
|
|
16
|
-
* // ... parsing operation
|
|
17
|
-
* }).pipe(
|
|
18
|
-
* Effect.catchTag("ParseError", (error) =>
|
|
19
|
-
* Effect.sync(() => console.error(`Parse error: ${error.message}`))
|
|
20
|
-
* )
|
|
21
|
-
* )
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @category Errors
|
|
25
|
-
*/
|
|
26
|
-
export class ParseError extends Data.TaggedError("ParseError") {
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Error thrown when serializing AST to HTML or Markdown fails.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```typescript
|
|
33
|
-
* import { Effect } from "effect"
|
|
34
|
-
* import { SerializeError } from "@knpkv/confluence-to-markdown/SchemaConverterError"
|
|
35
|
-
*
|
|
36
|
-
* Effect.gen(function* () {
|
|
37
|
-
* // ... serialization operation
|
|
38
|
-
* }).pipe(
|
|
39
|
-
* Effect.catchTag("SerializeError", (error) =>
|
|
40
|
-
* Effect.sync(() => console.error(`Serialize error: ${error.message}`))
|
|
41
|
-
* )
|
|
42
|
-
* )
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* @category Errors
|
|
46
|
-
*/
|
|
47
|
-
export class SerializeError extends Data.TaggedError("SerializeError") {
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Error thrown when migrating between schema versions fails.
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* import { Effect } from "effect"
|
|
55
|
-
* import { MigrationError } from "@knpkv/confluence-to-markdown/SchemaConverterError"
|
|
56
|
-
*
|
|
57
|
-
* Effect.gen(function* () {
|
|
58
|
-
* // ... migration operation
|
|
59
|
-
* }).pipe(
|
|
60
|
-
* Effect.catchTag("MigrationError", (error) =>
|
|
61
|
-
* Effect.sync(() =>
|
|
62
|
-
* console.error(`Migration error: ${error.nodeType} v${error.fromVersion} -> v${error.toVersion}`)
|
|
63
|
-
* )
|
|
64
|
-
* )
|
|
65
|
-
* )
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* @category Errors
|
|
69
|
-
*/
|
|
70
|
-
export class MigrationError extends Data.TaggedError("MigrationError") {
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Type guard to check if error is a SchemaConverterError.
|
|
74
|
-
*
|
|
75
|
-
* @param error - The error to check
|
|
76
|
-
* @returns True if error is a SchemaConverterError
|
|
77
|
-
*
|
|
78
|
-
* @category Utilities
|
|
79
|
-
*/
|
|
80
|
-
export const isSchemaConverterError = (error) => typeof error === "object" &&
|
|
81
|
-
error !== null &&
|
|
82
|
-
"_tag" in error &&
|
|
83
|
-
["ParseError", "SerializeError", "MigrationError"].includes(error._tag);
|
|
84
|
-
//# sourceMappingURL=SchemaConverterError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaConverterError.js","sourceRoot":"","sources":["../src/SchemaConverterError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AAEnC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,UAAW,SAAQ,IAAI,CAAC,WAAW,CAAC,YAAY,CAK3D;CAAG;AAEL;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,cAAe,SAAQ,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAInE;CAAG;AAEL;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,cAAe,SAAQ,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAKnE;CAAG;AASL;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAc,EAAiC,EAAE,CACtF,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACd,MAAM,IAAI,KAAK;IACf,CAAC,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,QAAQ,CACxD,KAA0B,CAAC,IAAI,CACjC,CAAA"}
|