@knpkv/confluence-to-markdown 0.2.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 +12 -0
- package/README.md +62 -0
- package/dist/Brand.d.ts +77 -0
- package/dist/Brand.d.ts.map +1 -0
- package/dist/Brand.js +44 -0
- package/dist/Brand.js.map +1 -0
- package/dist/ConfluenceClient.d.ts +140 -0
- package/dist/ConfluenceClient.d.ts.map +1 -0
- package/dist/ConfluenceClient.js +195 -0
- package/dist/ConfluenceClient.js.map +1 -0
- package/dist/ConfluenceConfig.d.ts +83 -0
- package/dist/ConfluenceConfig.d.ts.map +1 -0
- package/dist/ConfluenceConfig.js +122 -0
- package/dist/ConfluenceConfig.js.map +1 -0
- package/dist/ConfluenceError.d.ts +178 -0
- package/dist/ConfluenceError.d.ts.map +1 -0
- package/dist/ConfluenceError.js +131 -0
- package/dist/ConfluenceError.js.map +1 -0
- package/dist/LocalFileSystem.d.ts +85 -0
- package/dist/LocalFileSystem.d.ts.map +1 -0
- package/dist/LocalFileSystem.js +101 -0
- package/dist/LocalFileSystem.js.map +1 -0
- package/dist/MarkdownConverter.d.ts +50 -0
- package/dist/MarkdownConverter.d.ts.map +1 -0
- package/dist/MarkdownConverter.js +151 -0
- package/dist/MarkdownConverter.js.map +1 -0
- package/dist/Schemas.d.ts +225 -0
- package/dist/Schemas.d.ts.map +1 -0
- package/dist/Schemas.js +164 -0
- package/dist/Schemas.js.map +1 -0
- package/dist/SyncEngine.d.ts +132 -0
- package/dist/SyncEngine.d.ts.map +1 -0
- package/dist/SyncEngine.js +267 -0
- package/dist/SyncEngine.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +163 -0
- package/dist/bin.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/frontmatter.d.ts +38 -0
- package/dist/internal/frontmatter.d.ts.map +1 -0
- package/dist/internal/frontmatter.js +69 -0
- package/dist/internal/frontmatter.js.map +1 -0
- package/dist/internal/hashUtils.d.ts +11 -0
- package/dist/internal/hashUtils.d.ts.map +1 -0
- package/dist/internal/hashUtils.js +17 -0
- package/dist/internal/hashUtils.js.map +1 -0
- package/dist/internal/pathUtils.d.ts +41 -0
- package/dist/internal/pathUtils.d.ts.map +1 -0
- package/dist/internal/pathUtils.js +69 -0
- package/dist/internal/pathUtils.js.map +1 -0
- package/package.json +113 -0
- package/src/Brand.ts +104 -0
- package/src/ConfluenceClient.ts +387 -0
- package/src/ConfluenceConfig.ts +184 -0
- package/src/ConfluenceError.ts +193 -0
- package/src/LocalFileSystem.ts +225 -0
- package/src/MarkdownConverter.ts +187 -0
- package/src/Schemas.ts +235 -0
- package/src/SyncEngine.ts +429 -0
- package/src/bin.ts +269 -0
- package/src/index.ts +35 -0
- package/src/internal/frontmatter.ts +98 -0
- package/src/internal/hashUtils.ts +19 -0
- package/src/internal/pathUtils.ts +77 -0
- package/test/Brand.test.ts +72 -0
- package/test/MarkdownConverter.test.ts +108 -0
- package/test/Schemas.test.ts +99 -0
- package/tsconfig.json +32 -0
- package/vitest.config.integration.ts +12 -0
- package/vitest.config.ts +13 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
+
import * as Either from "effect/Either"
|
|
3
|
+
import * as Schema from "effect/Schema"
|
|
4
|
+
import type { ContentHash, PageId } from "../src/Brand.js"
|
|
5
|
+
import { ConfluenceConfigFileSchema, PageFrontMatterSchema } from "../src/Schemas.js"
|
|
6
|
+
|
|
7
|
+
describe("Schemas", () => {
|
|
8
|
+
describe("ConfluenceConfigFileSchema", () => {
|
|
9
|
+
it("decodes valid config", () => {
|
|
10
|
+
const config = {
|
|
11
|
+
rootPageId: "123456",
|
|
12
|
+
baseUrl: "https://mysite.atlassian.net"
|
|
13
|
+
}
|
|
14
|
+
const result = Schema.decodeUnknownEither(ConfluenceConfigFileSchema)(config)
|
|
15
|
+
expect(Either.isRight(result)).toBe(true)
|
|
16
|
+
if (Either.isRight(result)) {
|
|
17
|
+
expect(result.right.docsPath).toBe(".docs/confluence")
|
|
18
|
+
expect(result.right.excludePatterns).toEqual([])
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it("decodes config with all fields", () => {
|
|
23
|
+
const config = {
|
|
24
|
+
rootPageId: "123456",
|
|
25
|
+
baseUrl: "https://mysite.atlassian.net",
|
|
26
|
+
spaceKey: "DEV",
|
|
27
|
+
docsPath: "docs",
|
|
28
|
+
excludePatterns: ["*.tmp"]
|
|
29
|
+
}
|
|
30
|
+
const result = Schema.decodeUnknownEither(ConfluenceConfigFileSchema)(config)
|
|
31
|
+
expect(Either.isRight(result)).toBe(true)
|
|
32
|
+
if (Either.isRight(result)) {
|
|
33
|
+
expect(result.right.spaceKey).toBe("DEV")
|
|
34
|
+
expect(result.right.docsPath).toBe("docs")
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it("rejects invalid base URL", () => {
|
|
39
|
+
const config = {
|
|
40
|
+
rootPageId: "123456",
|
|
41
|
+
baseUrl: "http://invalid.com"
|
|
42
|
+
}
|
|
43
|
+
const result = Schema.decodeUnknownEither(ConfluenceConfigFileSchema)(config)
|
|
44
|
+
expect(Either.isLeft(result)).toBe(true)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it("rejects missing required fields", () => {
|
|
48
|
+
const config = { baseUrl: "https://mysite.atlassian.net" }
|
|
49
|
+
const result = Schema.decodeUnknownEither(ConfluenceConfigFileSchema)(config)
|
|
50
|
+
expect(Either.isLeft(result)).toBe(true)
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
describe("PageFrontMatterSchema", () => {
|
|
55
|
+
const validHash = "a".repeat(64) as ContentHash
|
|
56
|
+
|
|
57
|
+
it("decodes valid front matter", () => {
|
|
58
|
+
const fm = {
|
|
59
|
+
pageId: "123" as PageId,
|
|
60
|
+
version: 1,
|
|
61
|
+
title: "Test Page",
|
|
62
|
+
updated: new Date().toISOString(),
|
|
63
|
+
contentHash: validHash
|
|
64
|
+
}
|
|
65
|
+
const result = Schema.decodeUnknownEither(PageFrontMatterSchema)(fm)
|
|
66
|
+
expect(Either.isRight(result)).toBe(true)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it("decodes front matter with optional fields", () => {
|
|
70
|
+
const fm = {
|
|
71
|
+
pageId: "123" as PageId,
|
|
72
|
+
version: 2,
|
|
73
|
+
title: "Test Page",
|
|
74
|
+
updated: new Date().toISOString(),
|
|
75
|
+
parentId: "456" as PageId,
|
|
76
|
+
position: 0,
|
|
77
|
+
contentHash: validHash
|
|
78
|
+
}
|
|
79
|
+
const result = Schema.decodeUnknownEither(PageFrontMatterSchema)(fm)
|
|
80
|
+
expect(Either.isRight(result)).toBe(true)
|
|
81
|
+
if (Either.isRight(result)) {
|
|
82
|
+
expect(result.right.parentId).toBe("456")
|
|
83
|
+
expect(result.right.position).toBe(0)
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it("rejects negative version", () => {
|
|
88
|
+
const fm = {
|
|
89
|
+
pageId: "123",
|
|
90
|
+
version: -1,
|
|
91
|
+
title: "Test",
|
|
92
|
+
updated: new Date().toISOString(),
|
|
93
|
+
contentHash: validHash
|
|
94
|
+
}
|
|
95
|
+
const result = Schema.decodeUnknownEither(PageFrontMatterSchema)(fm)
|
|
96
|
+
expect(Either.isLeft(result)).toBe(true)
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
})
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "./dist",
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"strict": true,
|
|
10
|
+
"noImplicitAny": true,
|
|
11
|
+
"strictNullChecks": true,
|
|
12
|
+
"noUncheckedIndexedAccess": true,
|
|
13
|
+
"exactOptionalPropertyTypes": true,
|
|
14
|
+
"noImplicitReturns": true,
|
|
15
|
+
"noFallthroughCasesInSwitch": true,
|
|
16
|
+
"noUnusedLocals": false,
|
|
17
|
+
"noUnusedParameters": false,
|
|
18
|
+
"allowUnusedLabels": false,
|
|
19
|
+
"allowUnreachableCode": false,
|
|
20
|
+
"skipLibCheck": true,
|
|
21
|
+
"forceConsistentCasingInFileNames": true,
|
|
22
|
+
"moduleResolution": "bundler",
|
|
23
|
+
"module": "ESNext",
|
|
24
|
+
"target": "ES2022",
|
|
25
|
+
"lib": ["ES2022"],
|
|
26
|
+
"types": ["node"],
|
|
27
|
+
"esModuleInterop": true,
|
|
28
|
+
"resolveJsonModule": true
|
|
29
|
+
},
|
|
30
|
+
"include": ["src/**/*"],
|
|
31
|
+
"exclude": ["node_modules", "dist", "test"]
|
|
32
|
+
}
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config"
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
include: ["test/**/*.test.ts"],
|
|
6
|
+
exclude: ["test/integration.test.ts"],
|
|
7
|
+
globals: true,
|
|
8
|
+
environment: "node",
|
|
9
|
+
testTimeout: 30000,
|
|
10
|
+
hookTimeout: 30000,
|
|
11
|
+
teardownTimeout: 30000
|
|
12
|
+
}
|
|
13
|
+
})
|