@knpkv/confluence-to-markdown 0.2.0 → 0.4.2

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 (336) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/LICENSE +21 -0
  3. package/README.md +282 -14
  4. package/dist/ConfluenceAuth.d.ts +76 -0
  5. package/dist/ConfluenceAuth.d.ts.map +1 -0
  6. package/dist/ConfluenceAuth.js +366 -0
  7. package/dist/ConfluenceAuth.js.map +1 -0
  8. package/dist/ConfluenceClient.d.ts +26 -12
  9. package/dist/ConfluenceClient.d.ts.map +1 -1
  10. package/dist/ConfluenceClient.js +139 -97
  11. package/dist/ConfluenceClient.js.map +1 -1
  12. package/dist/ConfluenceConfig.d.ts +4 -24
  13. package/dist/ConfluenceConfig.d.ts.map +1 -1
  14. package/dist/ConfluenceConfig.js +45 -7
  15. package/dist/ConfluenceConfig.js.map +1 -1
  16. package/dist/ConfluenceError.d.ts +99 -16
  17. package/dist/ConfluenceError.d.ts.map +1 -1
  18. package/dist/ConfluenceError.js +88 -5
  19. package/dist/ConfluenceError.js.map +1 -1
  20. package/dist/GitError.d.ts +103 -0
  21. package/dist/GitError.d.ts.map +1 -0
  22. package/dist/GitError.js +85 -0
  23. package/dist/GitError.js.map +1 -0
  24. package/dist/GitService.d.ts +175 -0
  25. package/dist/GitService.d.ts.map +1 -0
  26. package/dist/GitService.js +431 -0
  27. package/dist/GitService.js.map +1 -0
  28. package/dist/LocalFileSystem.d.ts +29 -4
  29. package/dist/LocalFileSystem.d.ts.map +1 -1
  30. package/dist/LocalFileSystem.js +80 -6
  31. package/dist/LocalFileSystem.js.map +1 -1
  32. package/dist/MarkdownConverter.d.ts +49 -2
  33. package/dist/MarkdownConverter.d.ts.map +1 -1
  34. package/dist/MarkdownConverter.js +73 -111
  35. package/dist/MarkdownConverter.js.map +1 -1
  36. package/dist/SchemaConverterError.d.ts +108 -0
  37. package/dist/SchemaConverterError.d.ts.map +1 -0
  38. package/dist/SchemaConverterError.js +84 -0
  39. package/dist/SchemaConverterError.js.map +1 -0
  40. package/dist/Schemas.d.ts +225 -1
  41. package/dist/Schemas.d.ts.map +1 -1
  42. package/dist/Schemas.js +155 -6
  43. package/dist/Schemas.js.map +1 -1
  44. package/dist/SyncEngine.d.ts +30 -20
  45. package/dist/SyncEngine.d.ts.map +1 -1
  46. package/dist/SyncEngine.js +566 -117
  47. package/dist/SyncEngine.js.map +1 -1
  48. package/dist/ast/BlockNode.d.ts +468 -0
  49. package/dist/ast/BlockNode.d.ts.map +1 -0
  50. package/dist/ast/BlockNode.js +319 -0
  51. package/dist/ast/BlockNode.js.map +1 -0
  52. package/dist/ast/Document.d.ts +244 -0
  53. package/dist/ast/Document.d.ts.map +1 -0
  54. package/dist/ast/Document.js +69 -0
  55. package/dist/ast/Document.js.map +1 -0
  56. package/dist/ast/InlineNode.d.ts +477 -0
  57. package/dist/ast/InlineNode.d.ts.map +1 -0
  58. package/dist/ast/InlineNode.js +263 -0
  59. package/dist/ast/InlineNode.js.map +1 -0
  60. package/dist/ast/MacroNode.d.ts +267 -0
  61. package/dist/ast/MacroNode.d.ts.map +1 -0
  62. package/dist/ast/MacroNode.js +164 -0
  63. package/dist/ast/MacroNode.js.map +1 -0
  64. package/dist/ast/index.d.ts +10 -0
  65. package/dist/ast/index.d.ts.map +1 -0
  66. package/dist/ast/index.js +14 -0
  67. package/dist/ast/index.js.map +1 -0
  68. package/dist/bin.js +33 -149
  69. package/dist/bin.js.map +1 -1
  70. package/dist/commands/auth.d.ts +15 -0
  71. package/dist/commands/auth.d.ts.map +1 -0
  72. package/dist/commands/auth.js +86 -0
  73. package/dist/commands/auth.js.map +1 -0
  74. package/dist/commands/clone.d.ts +12 -0
  75. package/dist/commands/clone.d.ts.map +1 -0
  76. package/dist/commands/clone.js +93 -0
  77. package/dist/commands/clone.js.map +1 -0
  78. package/dist/commands/delete.d.ts +13 -0
  79. package/dist/commands/delete.d.ts.map +1 -0
  80. package/dist/commands/delete.js +48 -0
  81. package/dist/commands/delete.js.map +1 -0
  82. package/dist/commands/errorHandler.d.ts +14 -0
  83. package/dist/commands/errorHandler.d.ts.map +1 -0
  84. package/dist/commands/errorHandler.js +33 -0
  85. package/dist/commands/errorHandler.js.map +1 -0
  86. package/dist/commands/git.d.ts +22 -0
  87. package/dist/commands/git.d.ts.map +1 -0
  88. package/dist/commands/git.js +72 -0
  89. package/dist/commands/git.js.map +1 -0
  90. package/dist/commands/index.d.ts +11 -0
  91. package/dist/commands/index.d.ts.map +1 -0
  92. package/dist/commands/index.js +11 -0
  93. package/dist/commands/index.js.map +1 -0
  94. package/dist/commands/layers.d.ts +31 -0
  95. package/dist/commands/layers.d.ts.map +1 -0
  96. package/dist/commands/layers.js +137 -0
  97. package/dist/commands/layers.js.map +1 -0
  98. package/dist/commands/new.d.ts +9 -0
  99. package/dist/commands/new.d.ts.map +1 -0
  100. package/dist/commands/new.js +80 -0
  101. package/dist/commands/new.js.map +1 -0
  102. package/dist/commands/pageTree.d.ts +18 -0
  103. package/dist/commands/pageTree.d.ts.map +1 -0
  104. package/dist/commands/pageTree.js +20 -0
  105. package/dist/commands/pageTree.js.map +1 -0
  106. package/dist/commands/shared.d.ts +15 -0
  107. package/dist/commands/shared.d.ts.map +1 -0
  108. package/dist/commands/shared.js +27 -0
  109. package/dist/commands/shared.js.map +1 -0
  110. package/dist/commands/sync.d.ts +15 -0
  111. package/dist/commands/sync.d.ts.map +1 -0
  112. package/dist/commands/sync.js +101 -0
  113. package/dist/commands/sync.js.map +1 -0
  114. package/dist/index.d.ts +10 -1
  115. package/dist/index.d.ts.map +1 -1
  116. package/dist/index.js +14 -0
  117. package/dist/index.js.map +1 -1
  118. package/dist/internal/NodeLayers.d.ts +7 -0
  119. package/dist/internal/NodeLayers.d.ts.map +1 -0
  120. package/dist/internal/NodeLayers.js +19 -0
  121. package/dist/internal/NodeLayers.js.map +1 -0
  122. package/dist/internal/frontmatter.d.ts +10 -0
  123. package/dist/internal/frontmatter.d.ts.map +1 -1
  124. package/dist/internal/frontmatter.js +16 -0
  125. package/dist/internal/frontmatter.js.map +1 -1
  126. package/dist/internal/gitCommands.d.ts +78 -0
  127. package/dist/internal/gitCommands.d.ts.map +1 -0
  128. package/dist/internal/gitCommands.js +156 -0
  129. package/dist/internal/gitCommands.js.map +1 -0
  130. package/dist/internal/hashUtils.d.ts +42 -1
  131. package/dist/internal/hashUtils.d.ts.map +1 -1
  132. package/dist/internal/hashUtils.js +38 -2
  133. package/dist/internal/hashUtils.js.map +1 -1
  134. package/dist/internal/oauthServer.d.ts +55 -0
  135. package/dist/internal/oauthServer.d.ts.map +1 -0
  136. package/dist/internal/oauthServer.js +110 -0
  137. package/dist/internal/oauthServer.js.map +1 -0
  138. package/dist/internal/pathUtils.d.ts +21 -4
  139. package/dist/internal/pathUtils.d.ts.map +1 -1
  140. package/dist/internal/pathUtils.js +24 -13
  141. package/dist/internal/pathUtils.js.map +1 -1
  142. package/dist/internal/tokenStorage.d.ts +75 -0
  143. package/dist/internal/tokenStorage.d.ts.map +1 -0
  144. package/dist/internal/tokenStorage.js +149 -0
  145. package/dist/internal/tokenStorage.js.map +1 -0
  146. package/dist/internal/userCache.d.ts +42 -0
  147. package/dist/internal/userCache.d.ts.map +1 -0
  148. package/dist/internal/userCache.js +51 -0
  149. package/dist/internal/userCache.js.map +1 -0
  150. package/dist/parsers/ConfluenceParser.d.ts +26 -0
  151. package/dist/parsers/ConfluenceParser.d.ts.map +1 -0
  152. package/dist/parsers/ConfluenceParser.js +792 -0
  153. package/dist/parsers/ConfluenceParser.js.map +1 -0
  154. package/dist/parsers/MarkdownParser.d.ts +26 -0
  155. package/dist/parsers/MarkdownParser.d.ts.map +1 -0
  156. package/dist/parsers/MarkdownParser.js +873 -0
  157. package/dist/parsers/MarkdownParser.js.map +1 -0
  158. package/dist/parsers/index.d.ts +8 -0
  159. package/dist/parsers/index.d.ts.map +1 -0
  160. package/dist/parsers/index.js +8 -0
  161. package/dist/parsers/index.js.map +1 -0
  162. package/dist/schemas/ConfluenceSchema.d.ts +21 -0
  163. package/dist/schemas/ConfluenceSchema.d.ts.map +1 -0
  164. package/dist/schemas/ConfluenceSchema.js +38 -0
  165. package/dist/schemas/ConfluenceSchema.js.map +1 -0
  166. package/dist/schemas/ConversionSchema.d.ts +35 -0
  167. package/dist/schemas/ConversionSchema.d.ts.map +1 -0
  168. package/dist/schemas/ConversionSchema.js +208 -0
  169. package/dist/schemas/ConversionSchema.js.map +1 -0
  170. package/dist/schemas/MarkdownSchema.d.ts +21 -0
  171. package/dist/schemas/MarkdownSchema.d.ts.map +1 -0
  172. package/dist/schemas/MarkdownSchema.js +38 -0
  173. package/dist/schemas/MarkdownSchema.js.map +1 -0
  174. package/dist/schemas/hast/HastFromHtml.d.ts +27 -0
  175. package/dist/schemas/hast/HastFromHtml.d.ts.map +1 -0
  176. package/dist/schemas/hast/HastFromHtml.js +107 -0
  177. package/dist/schemas/hast/HastFromHtml.js.map +1 -0
  178. package/dist/schemas/hast/HastSchema.d.ts +195 -0
  179. package/dist/schemas/hast/HastSchema.d.ts.map +1 -0
  180. package/dist/schemas/hast/HastSchema.js +183 -0
  181. package/dist/schemas/hast/HastSchema.js.map +1 -0
  182. package/dist/schemas/hast/index.d.ts +9 -0
  183. package/dist/schemas/hast/index.d.ts.map +1 -0
  184. package/dist/schemas/hast/index.js +3 -0
  185. package/dist/schemas/hast/index.js.map +1 -0
  186. package/dist/schemas/index.d.ts +14 -0
  187. package/dist/schemas/index.d.ts.map +1 -0
  188. package/dist/schemas/index.js +16 -0
  189. package/dist/schemas/index.js.map +1 -0
  190. package/dist/schemas/mdast/MdastFromMarkdown.d.ts +30 -0
  191. package/dist/schemas/mdast/MdastFromMarkdown.d.ts.map +1 -0
  192. package/dist/schemas/mdast/MdastFromMarkdown.js +79 -0
  193. package/dist/schemas/mdast/MdastFromMarkdown.js.map +1 -0
  194. package/dist/schemas/mdast/MdastSchema.d.ts +385 -0
  195. package/dist/schemas/mdast/MdastSchema.d.ts.map +1 -0
  196. package/dist/schemas/mdast/MdastSchema.js +266 -0
  197. package/dist/schemas/mdast/MdastSchema.js.map +1 -0
  198. package/dist/schemas/mdast/index.d.ts +10 -0
  199. package/dist/schemas/mdast/index.d.ts.map +1 -0
  200. package/dist/schemas/mdast/index.js +4 -0
  201. package/dist/schemas/mdast/index.js.map +1 -0
  202. package/dist/schemas/mdast/mdastToString.d.ts +13 -0
  203. package/dist/schemas/mdast/mdastToString.d.ts.map +1 -0
  204. package/dist/schemas/mdast/mdastToString.js +85 -0
  205. package/dist/schemas/mdast/mdastToString.js.map +1 -0
  206. package/dist/schemas/nodes/block/BlockSchema.d.ts +43 -0
  207. package/dist/schemas/nodes/block/BlockSchema.d.ts.map +1 -0
  208. package/dist/schemas/nodes/block/BlockSchema.js +634 -0
  209. package/dist/schemas/nodes/block/BlockSchema.js.map +1 -0
  210. package/dist/schemas/nodes/block/index.d.ts +7 -0
  211. package/dist/schemas/nodes/block/index.d.ts.map +1 -0
  212. package/dist/schemas/nodes/block/index.js +7 -0
  213. package/dist/schemas/nodes/block/index.js.map +1 -0
  214. package/dist/schemas/nodes/index.d.ts +9 -0
  215. package/dist/schemas/nodes/index.d.ts.map +1 -0
  216. package/dist/schemas/nodes/index.js +12 -0
  217. package/dist/schemas/nodes/index.js.map +1 -0
  218. package/dist/schemas/nodes/inline/InlineSchema.d.ts +48 -0
  219. package/dist/schemas/nodes/inline/InlineSchema.d.ts.map +1 -0
  220. package/dist/schemas/nodes/inline/InlineSchema.js +436 -0
  221. package/dist/schemas/nodes/inline/InlineSchema.js.map +1 -0
  222. package/dist/schemas/nodes/inline/index.d.ts +7 -0
  223. package/dist/schemas/nodes/inline/index.d.ts.map +1 -0
  224. package/dist/schemas/nodes/inline/index.js +7 -0
  225. package/dist/schemas/nodes/inline/index.js.map +1 -0
  226. package/dist/schemas/nodes/macro/MacroSchema.d.ts +27 -0
  227. package/dist/schemas/nodes/macro/MacroSchema.d.ts.map +1 -0
  228. package/dist/schemas/nodes/macro/MacroSchema.js +162 -0
  229. package/dist/schemas/nodes/macro/MacroSchema.js.map +1 -0
  230. package/dist/schemas/nodes/macro/index.d.ts +7 -0
  231. package/dist/schemas/nodes/macro/index.d.ts.map +1 -0
  232. package/dist/schemas/nodes/macro/index.js +7 -0
  233. package/dist/schemas/nodes/macro/index.js.map +1 -0
  234. package/dist/schemas/preprocessing/ConfluencePreprocessor.d.ts +24 -0
  235. package/dist/schemas/preprocessing/ConfluencePreprocessor.d.ts.map +1 -0
  236. package/dist/schemas/preprocessing/ConfluencePreprocessor.js +351 -0
  237. package/dist/schemas/preprocessing/ConfluencePreprocessor.js.map +1 -0
  238. package/dist/schemas/preprocessing/index.d.ts +8 -0
  239. package/dist/schemas/preprocessing/index.d.ts.map +1 -0
  240. package/dist/schemas/preprocessing/index.js +2 -0
  241. package/dist/schemas/preprocessing/index.js.map +1 -0
  242. package/dist/serializers/ConfluenceSerializer.d.ts +30 -0
  243. package/dist/serializers/ConfluenceSerializer.d.ts.map +1 -0
  244. package/dist/serializers/ConfluenceSerializer.js +551 -0
  245. package/dist/serializers/ConfluenceSerializer.js.map +1 -0
  246. package/dist/serializers/MarkdownSerializer.d.ts +34 -0
  247. package/dist/serializers/MarkdownSerializer.d.ts.map +1 -0
  248. package/dist/serializers/MarkdownSerializer.js +355 -0
  249. package/dist/serializers/MarkdownSerializer.js.map +1 -0
  250. package/dist/serializers/index.d.ts +8 -0
  251. package/dist/serializers/index.d.ts.map +1 -0
  252. package/dist/serializers/index.js +8 -0
  253. package/dist/serializers/index.js.map +1 -0
  254. package/package.json +32 -21
  255. package/src/ConfluenceAuth.ts +581 -0
  256. package/src/ConfluenceClient.ts +230 -165
  257. package/src/ConfluenceConfig.ts +63 -7
  258. package/src/ConfluenceError.ts +110 -14
  259. package/src/GitError.ts +92 -0
  260. package/src/GitService.ts +859 -0
  261. package/src/LocalFileSystem.ts +179 -9
  262. package/src/MarkdownConverter.ts +126 -122
  263. package/src/SchemaConverterError.ts +108 -0
  264. package/src/Schemas.ts +223 -6
  265. package/src/SyncEngine.ts +745 -162
  266. package/src/ast/BlockNode.ts +425 -0
  267. package/src/ast/Document.ts +90 -0
  268. package/src/ast/InlineNode.ts +323 -0
  269. package/src/ast/MacroNode.ts +245 -0
  270. package/src/ast/index.ts +83 -0
  271. package/src/bin.ts +50 -249
  272. package/src/commands/auth.ts +117 -0
  273. package/src/commands/clone.ts +145 -0
  274. package/src/commands/delete.ts +57 -0
  275. package/src/commands/errorHandler.ts +32 -0
  276. package/src/commands/git.ts +114 -0
  277. package/src/commands/index.ts +10 -0
  278. package/src/commands/layers.ts +211 -0
  279. package/src/commands/new.ts +99 -0
  280. package/src/commands/pageTree.ts +40 -0
  281. package/src/commands/shared.ts +35 -0
  282. package/src/commands/sync.ts +129 -0
  283. package/src/index.ts +21 -1
  284. package/src/internal/NodeLayers.ts +21 -0
  285. package/src/internal/frontmatter.ts +21 -0
  286. package/src/internal/gitCommands.ts +229 -0
  287. package/src/internal/hashUtils.ts +65 -3
  288. package/src/internal/oauthServer.ts +199 -0
  289. package/src/internal/pathUtils.ts +34 -17
  290. package/src/internal/tokenStorage.ts +240 -0
  291. package/src/internal/userCache.ts +90 -0
  292. package/src/parsers/ConfluenceParser.ts +950 -0
  293. package/src/parsers/MarkdownParser.ts +1198 -0
  294. package/src/parsers/index.ts +8 -0
  295. package/src/schemas/ConfluenceSchema.ts +56 -0
  296. package/src/schemas/ConversionSchema.ts +318 -0
  297. package/src/schemas/MarkdownSchema.ts +56 -0
  298. package/src/schemas/hast/HastFromHtml.ts +153 -0
  299. package/src/schemas/hast/HastSchema.ts +274 -0
  300. package/src/schemas/hast/index.ts +35 -0
  301. package/src/schemas/index.ts +20 -0
  302. package/src/schemas/mdast/MdastFromMarkdown.ts +118 -0
  303. package/src/schemas/mdast/MdastSchema.ts +566 -0
  304. package/src/schemas/mdast/index.ts +59 -0
  305. package/src/schemas/mdast/mdastToString.ts +102 -0
  306. package/src/schemas/nodes/block/BlockSchema.ts +773 -0
  307. package/src/schemas/nodes/block/index.ts +13 -0
  308. package/src/schemas/nodes/index.ts +20 -0
  309. package/src/schemas/nodes/inline/InlineSchema.ts +523 -0
  310. package/src/schemas/nodes/inline/index.ts +14 -0
  311. package/src/schemas/nodes/macro/MacroSchema.ts +226 -0
  312. package/src/schemas/nodes/macro/index.ts +6 -0
  313. package/src/schemas/preprocessing/ConfluencePreprocessor.ts +446 -0
  314. package/src/schemas/preprocessing/index.ts +8 -0
  315. package/src/serializers/ConfluenceSerializer.ts +717 -0
  316. package/src/serializers/MarkdownSerializer.ts +493 -0
  317. package/src/serializers/index.ts +8 -0
  318. package/test/GitService.test.ts +209 -0
  319. package/test/MarkdownConverter.test.ts +37 -3
  320. package/test/Schemas.test.ts +97 -2
  321. package/test/ast/BlockNode.test.ts +265 -0
  322. package/test/ast/Document.test.ts +126 -0
  323. package/test/ast/InlineNode.test.ts +161 -0
  324. package/test/fixtures/integration-test.html.fixture +103 -0
  325. package/test/fixtures/integration-test.md.expected +257 -0
  326. package/test/integration.test.ts +269 -0
  327. package/test/oauthServer.test.ts +50 -0
  328. package/test/parsers/ConfluenceParser.test.ts +283 -0
  329. package/test/schemas/ConfluencePreprocessor.test.ts +180 -0
  330. package/test/schemas/ConversionSchema.test.ts +159 -0
  331. package/test/schemas/HastSchema.test.ts +138 -0
  332. package/test/schemas/MdastSchema.test.ts +145 -0
  333. package/test/schemas/nodes/block/BlockSchema.test.ts +173 -0
  334. package/test/schemas/nodes/inline/InlineSchema.test.ts +198 -0
  335. package/test/schemas/nodes/macro/MacroSchema.test.ts +142 -0
  336. package/test/tokenStorage.test.ts +99 -0
@@ -0,0 +1,55 @@
1
+ import * as HttpServer from "@effect/platform/HttpServer";
2
+ import type { ServeError } from "@effect/platform/HttpServerError";
3
+ import * as Context from "effect/Context";
4
+ import * as Effect from "effect/Effect";
5
+ import * as Layer from "effect/Layer";
6
+ import { OAuthError } from "../ConfluenceError.js";
7
+ /**
8
+ * Factory service for creating HTTP servers.
9
+ * This allows mocking the server creation in tests.
10
+ *
11
+ * @category Services
12
+ */
13
+ export interface HttpServerFactory {
14
+ readonly createServerLayer: (port: number) => Layer.Layer<HttpServer.HttpServer, ServeError, never>;
15
+ }
16
+ declare const HttpServerFactoryTag_base: Context.TagClass<HttpServerFactoryTag, "@knpkv/confluence-to-markdown/HttpServerFactory", HttpServerFactory>;
17
+ /**
18
+ * Tag for the HttpServerFactory service.
19
+ *
20
+ * @category Services
21
+ */
22
+ export declare class HttpServerFactoryTag extends HttpServerFactoryTag_base {
23
+ }
24
+ /**
25
+ * Create a HttpServerFactory layer from a layer factory function.
26
+ * This allows injecting platform-specific implementations.
27
+ *
28
+ * @param createLayerFn - Function that creates HttpServer layer for a given port
29
+ * @returns Layer providing HttpServerFactory
30
+ *
31
+ * @category Layers
32
+ */
33
+ export declare const makeHttpServerFactory: (createLayerFn: (port: number) => Layer.Layer<HttpServer.HttpServer, ServeError, never>) => Layer.Layer<HttpServerFactoryTag>;
34
+ /**
35
+ * Result from the OAuth callback server.
36
+ */
37
+ export interface CallbackServerResult {
38
+ /** Promise that resolves with the authorization code */
39
+ readonly codePromise: Effect.Effect<string, OAuthError>;
40
+ /** Shutdown the callback server */
41
+ readonly shutdown: Effect.Effect<void, never>;
42
+ /** The port the server is listening on */
43
+ readonly port: number;
44
+ }
45
+ /**
46
+ * Start a local HTTP server to receive OAuth callback.
47
+ *
48
+ * @param expectedState - The state parameter to verify against CSRF
49
+ * @returns Server control interface with code promise, shutdown, and port
50
+ *
51
+ * @category OAuth
52
+ */
53
+ export declare const startCallbackServer: (expectedState: string) => Effect.Effect<CallbackServerResult, OAuthError, HttpServerFactoryTag>;
54
+ export {};
55
+ //# sourceMappingURL=oauthServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauthServer.d.ts","sourceRoot":"","sources":["../../src/internal/oauthServer.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAA;AACz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ttpRouter from "@effect/platform/HttpRouter";
7
+ import * as HttpServer from "@effect/platform/HttpServer";
8
+ import * as HttpServerRequest from "@effect/platform/HttpServerRequest";
9
+ import * as HttpServerResponse from "@effect/platform/HttpServerResponse";
10
+ import * as Context from "effect/Context";
11
+ import * as Deferred from "effect/Deferred";
12
+ import * as Effect from "effect/Effect";
13
+ import * as Fiber from "effect/Fiber";
14
+ import * as Layer from "effect/Layer";
15
+ import { OAuthError } from "../ConfluenceError.js";
16
+ const DEFAULT_PORT = 8585;
17
+ const MAX_PORT_ATTEMPTS = 10;
18
+ /**
19
+ * Tag for the HttpServerFactory service.
20
+ *
21
+ * @category Services
22
+ */
23
+ export class HttpServerFactoryTag extends Context.Tag("@knpkv/confluence-to-markdown/HttpServerFactory")() {
24
+ }
25
+ /**
26
+ * Create a HttpServerFactory layer from a layer factory function.
27
+ * This allows injecting platform-specific implementations.
28
+ *
29
+ * @param createLayerFn - Function that creates HttpServer layer for a given port
30
+ * @returns Layer providing HttpServerFactory
31
+ *
32
+ * @category Layers
33
+ */
34
+ export const makeHttpServerFactory = (createLayerFn) => Layer.succeed(HttpServerFactoryTag, {
35
+ createServerLayer: createLayerFn
36
+ });
37
+ /**
38
+ * Check if a port is available by attempting to start a server.
39
+ */
40
+ const isPortAvailable = (port) => Effect.gen(function* () {
41
+ const factory = yield* HttpServerFactoryTag;
42
+ const serverLayer = factory.createServerLayer(port);
43
+ // Try to acquire and immediately release
44
+ const result = yield* Layer.build(serverLayer).pipe(Effect.scoped, Effect.as(true), Effect.catchAll(() => Effect.succeed(false)));
45
+ return result;
46
+ });
47
+ /**
48
+ * Find an available port starting from the default.
49
+ */
50
+ const findAvailablePort = () => Effect.gen(function* () {
51
+ for (let attempt = 0; attempt < MAX_PORT_ATTEMPTS; attempt++) {
52
+ const port = DEFAULT_PORT + attempt;
53
+ const available = yield* isPortAvailable(port);
54
+ if (available) {
55
+ return port;
56
+ }
57
+ }
58
+ return yield* Effect.fail(new OAuthError({
59
+ step: "authorize",
60
+ cause: `Could not find available port (tried ${DEFAULT_PORT}-${DEFAULT_PORT + MAX_PORT_ATTEMPTS - 1}). Close other applications using these ports.`
61
+ }));
62
+ });
63
+ /**
64
+ * Start a local HTTP server to receive OAuth callback.
65
+ *
66
+ * @param expectedState - The state parameter to verify against CSRF
67
+ * @returns Server control interface with code promise, shutdown, and port
68
+ *
69
+ * @category OAuth
70
+ */
71
+ export const startCallbackServer = (expectedState) => Effect.gen(function* () {
72
+ const factory = yield* HttpServerFactoryTag;
73
+ const port = yield* findAvailablePort();
74
+ const deferred = yield* Deferred.make();
75
+ const readyDeferred = yield* Deferred.make();
76
+ const app = HttpRouter.empty.pipe(HttpRouter.get("/callback", Effect.gen(function* () {
77
+ const req = yield* HttpServerRequest.HttpServerRequest;
78
+ const url = new URL(req.url, `http://localhost:${port}`);
79
+ const code = url.searchParams.get("code");
80
+ const state = url.searchParams.get("state");
81
+ const error = url.searchParams.get("error");
82
+ const errorDescription = url.searchParams.get("error_description");
83
+ if (error) {
84
+ yield* Deferred.fail(deferred, new OAuthError({ step: "authorize", cause: errorDescription || error }));
85
+ return HttpServerResponse.html("<html><body><h1>Authorization Failed</h1><p>You can close this window.</p></body></html>");
86
+ }
87
+ if (state !== expectedState) {
88
+ yield* Deferred.fail(deferred, new OAuthError({ step: "authorize", cause: "State mismatch - possible CSRF attack" }));
89
+ return HttpServerResponse.html("<html><body><h1>Security Error</h1><p>State verification failed.</p></body></html>");
90
+ }
91
+ if (!code) {
92
+ yield* Deferred.fail(deferred, new OAuthError({ step: "authorize", cause: "No authorization code received" }));
93
+ return HttpServerResponse.html("<html><body><h1>Error</h1><p>No authorization code received.</p></body></html>");
94
+ }
95
+ yield* Deferred.succeed(deferred, code);
96
+ return HttpServerResponse.html("<html><body><h1>Success!</h1><p>You can close this window and return to the terminal.</p></body></html>");
97
+ })));
98
+ const serverLayer = factory.createServerLayer(port);
99
+ const serverFiber = yield* HttpServer.serve(app).pipe(Layer.provide(serverLayer), Layer.build, Effect.tap(() => Deferred.succeed(readyDeferred, undefined)), Effect.tapError((err) => Deferred.fail(readyDeferred, new OAuthError({ step: "authorize", cause: err }))),
100
+ // Keep the layer alive until fiber is interrupted
101
+ Effect.flatMap(() => Effect.never), Effect.scoped, Effect.fork);
102
+ // Wait for server to be ready (or fail)
103
+ yield* Deferred.await(readyDeferred);
104
+ return {
105
+ codePromise: Deferred.await(deferred),
106
+ shutdown: Fiber.interrupt(serverFiber).pipe(Effect.asVoid),
107
+ port
108
+ };
109
+ });
110
+ //# sourceMappingURL=oauthServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauthServer.js","sourceRoot":"","sources":["../../src/internal/oauthServer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAA;AAEzD,OAAO,KAAK,iBAAiB,MAAM,oCAAoC,CAAA;AACvE,OAAO,KAAK,kBAAkB,MAAM,qCAAqC,CAAA;AACzE,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAElD,MAAM,YAAY,GAAG,IAAI,CAAA;AACzB,MAAM,iBAAiB,GAAG,EAAE,CAAA;AAgB5B;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,OAAO,CAAC,GAAG,CAAC,iDAAiD,CAAC,EAGrG;CAAG;AAEN;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,aAAsF,EACnD,EAAE,CACrC,KAAK,CAAC,OAAO,CAAC,oBAAoB,EAAE;IAClC,iBAAiB,EAAE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DAAkD;IAClD,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAClC,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,IAAI,CACZ,CAAA;IAED,wCAAwC;IACxC,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IAEpC,OAAO;QACL,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QAC1D,IAAI;KACL,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Path utilities for converting page titles to file paths.
3
+ *
4
+ * @module
5
+ * @internal
6
+ */
7
+ import * as Path from "@effect/platform/Path";
8
+ import * as Effect from "effect/Effect";
1
9
  /**
2
10
  * Convert a page title to a URL-safe slug.
3
11
  * Prevents path traversal by only allowing alphanumeric characters and hyphens.
@@ -11,14 +19,23 @@ export declare const slugify: (title: string) => string;
11
19
  /**
12
20
  * Convert a page to a local file path.
13
21
  *
22
+ * Pages are always stored as `slug.md`. If a page has children,
23
+ * the children are stored in a `slug/` directory alongside the parent file.
24
+ *
25
+ * Example structure:
26
+ * - guide.md (page with children)
27
+ * - guide/ (directory for children)
28
+ * - getting-started.md
29
+ * - advanced.md
30
+ *
14
31
  * @param title - The page title
15
- * @param hasChildren - Whether the page has child pages
32
+ * @param _hasChildren - Whether the page has child pages (unused, kept for API compat)
16
33
  * @param parentPath - The parent directory path
17
34
  * @returns The local file path for the page
18
35
  *
19
36
  * @internal
20
37
  */
21
- export declare const pageToPath: (title: string, hasChildren: boolean, parentPath: string) => string;
38
+ export declare const pageToPath: (title: string, _hasChildren: boolean, parentPath: string) => Effect.Effect<string, never, Path.Path>;
22
39
  /**
23
40
  * Get the directory path for a page (used when creating children).
24
41
  *
@@ -28,7 +45,7 @@ export declare const pageToPath: (title: string, hasChildren: boolean, parentPat
28
45
  *
29
46
  * @internal
30
47
  */
31
- export declare const pageToDir: (title: string, parentPath: string) => string;
48
+ export declare const pageToDir: (title: string, parentPath: string) => Effect.Effect<string, never, Path.Path>;
32
49
  /**
33
50
  * Extract page slug from a file path.
34
51
  *
@@ -37,5 +54,5 @@ export declare const pageToDir: (title: string, parentPath: string) => string;
37
54
  *
38
55
  * @internal
39
56
  */
40
- export declare const pathToSlug: (filePath: string) => string;
57
+ export declare const pathToSlug: (filePath: string) => Effect.Effect<string, never, Path.Path>;
41
58
  //# sourceMappingURL=pathUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../../src/internal/pathUtils.ts"],"names":[],"mappings":"AAQA;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,MAAM,KAAG,MAWvC,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,MAAM,EACb,aAAa,OAAO,EACpB,YAAY,MAAM,KACjB,MAKF,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,EAAE,YAAY,MAAM,KAAG,MAG7D,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GAAI,UAAU,MAAM,KAAG,MAG7C,CAAA"}
1
+ {"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../../src/internal/pathUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAA;AAC7C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,MAAM,KAAG,MAWvC,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,MAAM,EACb,cAAc,OAAO,EACrB,YAAY,MAAM,KACjB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAMrC,CAAA;AAEJ;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,GACpB,OAAO,MAAM,EACb,YAAY,MAAM,KACjB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAKrC,CAAA;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GAAI,UAAU,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAIhF,CAAA"}
@@ -4,7 +4,8 @@
4
4
  * @module
5
5
  * @internal
6
6
  */
7
- import * as path from "node:path";
7
+ import * as Path from "@effect/platform/Path";
8
+ import * as Effect from "effect/Effect";
8
9
  /**
9
10
  * Convert a page title to a URL-safe slug.
10
11
  * Prevents path traversal by only allowing alphanumeric characters and hyphens.
@@ -28,19 +29,28 @@ export const slugify = (title) => {
28
29
  /**
29
30
  * Convert a page to a local file path.
30
31
  *
32
+ * Pages are always stored as `slug.md`. If a page has children,
33
+ * the children are stored in a `slug/` directory alongside the parent file.
34
+ *
35
+ * Example structure:
36
+ * - guide.md (page with children)
37
+ * - guide/ (directory for children)
38
+ * - getting-started.md
39
+ * - advanced.md
40
+ *
31
41
  * @param title - The page title
32
- * @param hasChildren - Whether the page has child pages
42
+ * @param _hasChildren - Whether the page has child pages (unused, kept for API compat)
33
43
  * @param parentPath - The parent directory path
34
44
  * @returns The local file path for the page
35
45
  *
36
46
  * @internal
37
47
  */
38
- export const pageToPath = (title, hasChildren, parentPath) => {
48
+ export const pageToPath = (title, _hasChildren, parentPath) => Effect.gen(function* () {
49
+ const path = yield* Path.Path;
39
50
  const slug = slugify(title);
40
- return hasChildren
41
- ? path.join(parentPath, slug, "index.md")
42
- : path.join(parentPath, `${slug}.md`);
43
- };
51
+ // Always use slug.md, children go in slug/ directory
52
+ return path.join(parentPath, `${slug}.md`);
53
+ });
44
54
  /**
45
55
  * Get the directory path for a page (used when creating children).
46
56
  *
@@ -50,10 +60,11 @@ export const pageToPath = (title, hasChildren, parentPath) => {
50
60
  *
51
61
  * @internal
52
62
  */
53
- export const pageToDir = (title, parentPath) => {
63
+ export const pageToDir = (title, parentPath) => Effect.gen(function* () {
64
+ const path = yield* Path.Path;
54
65
  const slug = slugify(title);
55
66
  return path.join(parentPath, slug);
56
- };
67
+ });
57
68
  /**
58
69
  * Extract page slug from a file path.
59
70
  *
@@ -62,8 +73,8 @@ export const pageToDir = (title, parentPath) => {
62
73
  *
63
74
  * @internal
64
75
  */
65
- export const pathToSlug = (filePath) => {
66
- const basename = path.basename(filePath, ".md");
67
- return basename === "index" ? path.basename(path.dirname(filePath)) : basename;
68
- };
76
+ export const pathToSlug = (filePath) => Effect.gen(function* () {
77
+ const path = yield* Path.Path;
78
+ return path.basename(filePath, ".md");
79
+ });
69
80
  //# sourceMappingURL=pathUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pathUtils.js","sourceRoot":"","sources":["../../src/internal/pathUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAa,EAAU,EAAE;IAC/C,MAAM,IAAI,GAAG,KAAK;SACf,WAAW,EAAE;SACb,SAAS,CAAC,KAAK,CAAC;SAChB,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC,oBAAoB;SACpD,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,sEAAsE;SAClG,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,gCAAgC;SACxD,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA,CAAC,eAAe;IAEpC,6DAA6D;IAC7D,OAAO,IAAI,IAAI,UAAU,CAAA;AAC3B,CAAC,CAAA;AAED;;;;;;;;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IAAI,CAAC,IAAI,CAAA;IAC7B,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;AACvC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Token storage for OAuth credentials.
3
+ *
4
+ * @module
5
+ */
6
+ import * as FileSystem from "@effect/platform/FileSystem";
7
+ import * as Path from "@effect/platform/Path";
8
+ import * as Context from "effect/Context";
9
+ import * as Effect from "effect/Effect";
10
+ import * as Layer from "effect/Layer";
11
+ import { FileSystemError } from "../ConfluenceError.js";
12
+ import { type OAuthConfig, type OAuthToken } from "../Schemas.js";
13
+ /**
14
+ * Service for getting the home directory.
15
+ * This allows mocking in tests.
16
+ *
17
+ * @category Services
18
+ */
19
+ export interface HomeDirectory {
20
+ readonly get: () => Effect.Effect<string>;
21
+ }
22
+ declare const HomeDirectoryTag_base: Context.TagClass<HomeDirectoryTag, "@knpkv/confluence-to-markdown/HomeDirectory", HomeDirectory>;
23
+ /**
24
+ * Tag for the HomeDirectory service.
25
+ *
26
+ * @category Services
27
+ */
28
+ export declare class HomeDirectoryTag extends HomeDirectoryTag_base {
29
+ }
30
+ /**
31
+ * Default implementation using process.env.HOME.
32
+ *
33
+ * @category Layers
34
+ */
35
+ export declare const HomeDirectoryLive: Layer.Layer<HomeDirectoryTag>;
36
+ /**
37
+ * Load stored OAuth token from disk.
38
+ *
39
+ * @returns The stored token or null if not found/invalid
40
+ *
41
+ * @category Token Storage
42
+ */
43
+ export declare const loadToken: () => Effect.Effect<OAuthToken | null, FileSystemError, FileSystem.FileSystem | Path.Path | HomeDirectoryTag>;
44
+ /**
45
+ * Save OAuth token to disk with secure permissions.
46
+ *
47
+ * @param token - The token to save
48
+ *
49
+ * @category Token Storage
50
+ */
51
+ export declare const saveToken: (token: OAuthToken) => Effect.Effect<void, FileSystemError, FileSystem.FileSystem | Path.Path | HomeDirectoryTag>;
52
+ /**
53
+ * Delete stored OAuth token.
54
+ *
55
+ * @category Token Storage
56
+ */
57
+ export declare const deleteToken: () => Effect.Effect<void, FileSystemError, FileSystem.FileSystem | Path.Path | HomeDirectoryTag>;
58
+ /**
59
+ * Load OAuth client configuration from disk.
60
+ *
61
+ * @returns The stored config or null if not found/invalid
62
+ *
63
+ * @category OAuth Config
64
+ */
65
+ export declare const loadOAuthConfig: () => Effect.Effect<OAuthConfig | null, FileSystemError, FileSystem.FileSystem | Path.Path | HomeDirectoryTag>;
66
+ /**
67
+ * Save OAuth client configuration to disk with secure permissions.
68
+ *
69
+ * @param config - The config to save
70
+ *
71
+ * @category OAuth Config
72
+ */
73
+ export declare const saveOAuthConfig: (config: OAuthConfig) => Effect.Effect<void, FileSystemError, FileSystem.FileSystem | Path.Path | HomeDirectoryTag>;
74
+ export {};
75
+ //# sourceMappingURL=tokenStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenStorage.d.ts","sourceRoot":"","sources":["../../src/internal/tokenStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAA;AAC7C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,KAAK,WAAW,EAAqB,KAAK,UAAU,EAAoB,MAAM,eAAe,CAAA;AAMtG;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;CAC1C;;AAED;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,qBAGnC;CAAG;AAEN;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAK3D,CAAA;AAiCD;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,QAAO,MAAM,CAAC,MAAM,CACxC,UAAU,GAAG,IAAI,EACjB,eAAe,EACf,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,GAAG,gBAAgB,CA6BlD,CAAA;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GACpB,OAAO,UAAU,KAChB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAkBxF,CAAA;AAEJ;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAO,MAAM,CAAC,MAAM,CAC1C,IAAI,EACJ,eAAe,EACf,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAUlD,CAAA;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,QAAO,MAAM,CAAC,MAAM,CAC9C,WAAW,GAAG,IAAI,EAClB,eAAe,EACf,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,GAAG,gBAAgB,CA6BlD,CAAA;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAC1B,QAAQ,WAAW,KAClB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAkBxF,CAAA"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Token storage for OAuth credentials.
3
+ *
4
+ * @module
5
+ */
6
+ import * as FileSystem from "@effect/platform/FileSystem";
7
+ import * as Path from "@effect/platform/Path";
8
+ import * as Context from "effect/Context";
9
+ import * as Effect from "effect/Effect";
10
+ import * as Layer from "effect/Layer";
11
+ import * as Schema from "effect/Schema";
12
+ import { FileSystemError } from "../ConfluenceError.js";
13
+ import { OAuthConfigSchema, OAuthTokenSchema } from "../Schemas.js";
14
+ const TOKEN_DIR_NAME = ".confluence";
15
+ const TOKEN_FILE_NAME = "auth.json";
16
+ const CONFIG_FILE_NAME = "config.json";
17
+ /**
18
+ * Tag for the HomeDirectory service.
19
+ *
20
+ * @category Services
21
+ */
22
+ export class HomeDirectoryTag extends Context.Tag("@knpkv/confluence-to-markdown/HomeDirectory")() {
23
+ }
24
+ /**
25
+ * Default implementation using process.env.HOME.
26
+ *
27
+ * @category Layers
28
+ */
29
+ export const HomeDirectoryLive = Layer.succeed(HomeDirectoryTag, {
30
+ get: () => Effect.sync(() => process.env.HOME ?? process.env.USERPROFILE ?? "/")
31
+ });
32
+ /**
33
+ * Get the token directory path.
34
+ */
35
+ const getTokenDir = () => Effect.gen(function* () {
36
+ const homeDir = yield* HomeDirectoryTag;
37
+ const path = yield* Path.Path;
38
+ const home = yield* homeDir.get();
39
+ return path.join(home, TOKEN_DIR_NAME);
40
+ });
41
+ /**
42
+ * Get the token file path.
43
+ */
44
+ const getTokenPath = () => Effect.gen(function* () {
45
+ const path = yield* Path.Path;
46
+ const tokenDir = yield* getTokenDir();
47
+ return path.join(tokenDir, TOKEN_FILE_NAME);
48
+ });
49
+ /**
50
+ * Get the config file path.
51
+ */
52
+ const getConfigPath = () => Effect.gen(function* () {
53
+ const path = yield* Path.Path;
54
+ const tokenDir = yield* getTokenDir();
55
+ return path.join(tokenDir, CONFIG_FILE_NAME);
56
+ });
57
+ /**
58
+ * Load stored OAuth token from disk.
59
+ *
60
+ * @returns The stored token or null if not found/invalid
61
+ *
62
+ * @category Token Storage
63
+ */
64
+ export const loadToken = () => Effect.gen(function* () {
65
+ const fs = yield* FileSystem.FileSystem;
66
+ const tokenPath = yield* getTokenPath();
67
+ const exists = yield* fs.exists(tokenPath).pipe(Effect.catchAll(() => Effect.succeed(false)));
68
+ if (!exists) {
69
+ return null;
70
+ }
71
+ const content = yield* fs.readFileString(tokenPath).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "read", path: tokenPath, cause })));
72
+ let parsed;
73
+ try {
74
+ parsed = JSON.parse(content);
75
+ }
76
+ catch {
77
+ return null;
78
+ }
79
+ const decoded = yield* Schema.decodeUnknown(OAuthTokenSchema)(parsed).pipe(Effect.catchAll(() => Effect.succeed(null)));
80
+ return decoded;
81
+ });
82
+ /**
83
+ * Save OAuth token to disk with secure permissions.
84
+ *
85
+ * @param token - The token to save
86
+ *
87
+ * @category Token Storage
88
+ */
89
+ export const saveToken = (token) => Effect.gen(function* () {
90
+ const fs = yield* FileSystem.FileSystem;
91
+ const tokenDir = yield* getTokenDir();
92
+ const tokenPath = yield* getTokenPath();
93
+ yield* fs.makeDirectory(tokenDir, { recursive: true }).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "mkdir", path: tokenDir, cause })));
94
+ yield* fs.writeFileString(tokenPath, JSON.stringify(token, null, 2)).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "write", path: tokenPath, cause })));
95
+ // Set secure permissions (owner only)
96
+ yield* fs.chmod(tokenPath, 0o600).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "write", path: tokenPath, cause })));
97
+ });
98
+ /**
99
+ * Delete stored OAuth token.
100
+ *
101
+ * @category Token Storage
102
+ */
103
+ export const deleteToken = () => Effect.gen(function* () {
104
+ const fs = yield* FileSystem.FileSystem;
105
+ const tokenPath = yield* getTokenPath();
106
+ yield* fs.remove(tokenPath).pipe(Effect.catchAll(() => Effect.void), Effect.mapError((cause) => new FileSystemError({ operation: "delete", path: tokenPath, cause })));
107
+ });
108
+ /**
109
+ * Load OAuth client configuration from disk.
110
+ *
111
+ * @returns The stored config or null if not found/invalid
112
+ *
113
+ * @category OAuth Config
114
+ */
115
+ export const loadOAuthConfig = () => Effect.gen(function* () {
116
+ const fs = yield* FileSystem.FileSystem;
117
+ const configPath = yield* getConfigPath();
118
+ const exists = yield* fs.exists(configPath).pipe(Effect.catchAll(() => Effect.succeed(false)));
119
+ if (!exists) {
120
+ return null;
121
+ }
122
+ const content = yield* fs.readFileString(configPath).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "read", path: configPath, cause })));
123
+ let parsed;
124
+ try {
125
+ parsed = JSON.parse(content);
126
+ }
127
+ catch {
128
+ return null;
129
+ }
130
+ const decoded = yield* Schema.decodeUnknown(OAuthConfigSchema)(parsed).pipe(Effect.catchAll(() => Effect.succeed(null)));
131
+ return decoded;
132
+ });
133
+ /**
134
+ * Save OAuth client configuration to disk with secure permissions.
135
+ *
136
+ * @param config - The config to save
137
+ *
138
+ * @category OAuth Config
139
+ */
140
+ export const saveOAuthConfig = (config) => Effect.gen(function* () {
141
+ const fs = yield* FileSystem.FileSystem;
142
+ const tokenDir = yield* getTokenDir();
143
+ const configPath = yield* getConfigPath();
144
+ yield* fs.makeDirectory(tokenDir, { recursive: true }).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "mkdir", path: tokenDir, cause })));
145
+ yield* fs.writeFileString(configPath, JSON.stringify(config, null, 2)).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "write", path: configPath, cause })));
146
+ // Set secure permissions (owner only)
147
+ yield* fs.chmod(configPath, 0o600).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "write", path: configPath, cause })));
148
+ });
149
+ //# sourceMappingURL=tokenStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenStorage.js","sourceRoot":"","sources":["../../src/internal/tokenStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAA;AAC7C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAoB,iBAAiB,EAAmB,gBAAgB,EAAE,MAAM,eAAe,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EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAC/F,CAAA;IAED,KAAK,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CACzE,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,CACjG,CAAA;IAED,sCAAsC;IACtC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,IAAI,CACrC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,CACjG,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * In-memory cache for Atlassian user info.
3
+ *
4
+ * @module
5
+ */
6
+ import * as Context from "effect/Context";
7
+ import * as Effect from "effect/Effect";
8
+ import * as Layer from "effect/Layer";
9
+ import type { AtlassianUser } from "../Schemas.js";
10
+ declare const UserCache_base: Context.TagClass<UserCache, "@knpkv/confluence-to-markdown/UserCache", {
11
+ /**
12
+ * Get user from cache, or fetch and cache if not present.
13
+ */
14
+ readonly getOrFetch: (accountId: string, fetch: (accountId: string) => Effect.Effect<AtlassianUser, unknown>) => Effect.Effect<AtlassianUser, unknown>;
15
+ /**
16
+ * Get user from cache only (no fetch).
17
+ */
18
+ readonly get: (accountId: string) => Effect.Effect<AtlassianUser | undefined>;
19
+ /**
20
+ * Put user into cache.
21
+ */
22
+ readonly put: (accountId: string, user: AtlassianUser) => Effect.Effect<void>;
23
+ /**
24
+ * Clear the cache.
25
+ */
26
+ readonly clear: () => Effect.Effect<void>;
27
+ }>;
28
+ /**
29
+ * User cache service for caching Atlassian user lookups.
30
+ *
31
+ * @category Cache
32
+ */
33
+ export declare class UserCache extends UserCache_base {
34
+ }
35
+ /**
36
+ * Layer that provides UserCache.
37
+ *
38
+ * @category Layers
39
+ */
40
+ export declare const UserCacheLayer: Layer.Layer<UserCache>;
41
+ export {};
42
+ //# sourceMappingURL=userCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userCache.d.ts","sourceRoot":"","sources":["../../src/internal/userCache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;;IAU9C;;OAEG;yBACkB,CACnB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,KAChE,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC;IAE1C;;OAEG;kBACW,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC;IAE7E;;OAEG;kBACW,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;IAE7E;;OAEG;oBACa,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;;AA7B7C;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,cA0B5B;CAAG;AA0CN;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAiC,CAAA"}