@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.
Files changed (74) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +62 -0
  3. package/dist/Brand.d.ts +77 -0
  4. package/dist/Brand.d.ts.map +1 -0
  5. package/dist/Brand.js +44 -0
  6. package/dist/Brand.js.map +1 -0
  7. package/dist/ConfluenceClient.d.ts +140 -0
  8. package/dist/ConfluenceClient.d.ts.map +1 -0
  9. package/dist/ConfluenceClient.js +195 -0
  10. package/dist/ConfluenceClient.js.map +1 -0
  11. package/dist/ConfluenceConfig.d.ts +83 -0
  12. package/dist/ConfluenceConfig.d.ts.map +1 -0
  13. package/dist/ConfluenceConfig.js +122 -0
  14. package/dist/ConfluenceConfig.js.map +1 -0
  15. package/dist/ConfluenceError.d.ts +178 -0
  16. package/dist/ConfluenceError.d.ts.map +1 -0
  17. package/dist/ConfluenceError.js +131 -0
  18. package/dist/ConfluenceError.js.map +1 -0
  19. package/dist/LocalFileSystem.d.ts +85 -0
  20. package/dist/LocalFileSystem.d.ts.map +1 -0
  21. package/dist/LocalFileSystem.js +101 -0
  22. package/dist/LocalFileSystem.js.map +1 -0
  23. package/dist/MarkdownConverter.d.ts +50 -0
  24. package/dist/MarkdownConverter.d.ts.map +1 -0
  25. package/dist/MarkdownConverter.js +151 -0
  26. package/dist/MarkdownConverter.js.map +1 -0
  27. package/dist/Schemas.d.ts +225 -0
  28. package/dist/Schemas.d.ts.map +1 -0
  29. package/dist/Schemas.js +164 -0
  30. package/dist/Schemas.js.map +1 -0
  31. package/dist/SyncEngine.d.ts +132 -0
  32. package/dist/SyncEngine.d.ts.map +1 -0
  33. package/dist/SyncEngine.js +267 -0
  34. package/dist/SyncEngine.js.map +1 -0
  35. package/dist/bin.d.ts +3 -0
  36. package/dist/bin.d.ts.map +1 -0
  37. package/dist/bin.js +163 -0
  38. package/dist/bin.js.map +1 -0
  39. package/dist/index.d.ts +16 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +16 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/internal/frontmatter.d.ts +38 -0
  44. package/dist/internal/frontmatter.d.ts.map +1 -0
  45. package/dist/internal/frontmatter.js +69 -0
  46. package/dist/internal/frontmatter.js.map +1 -0
  47. package/dist/internal/hashUtils.d.ts +11 -0
  48. package/dist/internal/hashUtils.d.ts.map +1 -0
  49. package/dist/internal/hashUtils.js +17 -0
  50. package/dist/internal/hashUtils.js.map +1 -0
  51. package/dist/internal/pathUtils.d.ts +41 -0
  52. package/dist/internal/pathUtils.d.ts.map +1 -0
  53. package/dist/internal/pathUtils.js +69 -0
  54. package/dist/internal/pathUtils.js.map +1 -0
  55. package/package.json +113 -0
  56. package/src/Brand.ts +104 -0
  57. package/src/ConfluenceClient.ts +387 -0
  58. package/src/ConfluenceConfig.ts +184 -0
  59. package/src/ConfluenceError.ts +193 -0
  60. package/src/LocalFileSystem.ts +225 -0
  61. package/src/MarkdownConverter.ts +187 -0
  62. package/src/Schemas.ts +235 -0
  63. package/src/SyncEngine.ts +429 -0
  64. package/src/bin.ts +269 -0
  65. package/src/index.ts +35 -0
  66. package/src/internal/frontmatter.ts +98 -0
  67. package/src/internal/hashUtils.ts +19 -0
  68. package/src/internal/pathUtils.ts +77 -0
  69. package/test/Brand.test.ts +72 -0
  70. package/test/MarkdownConverter.test.ts +108 -0
  71. package/test/Schemas.test.ts +99 -0
  72. package/tsconfig.json +32 -0
  73. package/vitest.config.integration.ts +12 -0
  74. 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
+ }
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from "vitest/config"
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ include: ["test/integration.test.ts"],
6
+ globals: true,
7
+ environment: "node",
8
+ testTimeout: 60000,
9
+ hookTimeout: 60000,
10
+ teardownTimeout: 60000
11
+ }
12
+ })
@@ -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
+ })