@knpkv/atlassian-common 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 (121) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE +21 -0
  3. package/README.md +107 -0
  4. package/dist/Brand.d.ts +118 -0
  5. package/dist/Brand.d.ts.map +1 -0
  6. package/dist/Brand.js +107 -0
  7. package/dist/Brand.js.map +1 -0
  8. package/dist/Hash.d.ts +53 -0
  9. package/dist/Hash.d.ts.map +1 -0
  10. package/dist/Hash.js +63 -0
  11. package/dist/Hash.js.map +1 -0
  12. package/dist/SerializeError.d.ts +48 -0
  13. package/dist/SerializeError.d.ts.map +1 -0
  14. package/dist/SerializeError.js +42 -0
  15. package/dist/SerializeError.js.map +1 -0
  16. package/dist/ast/BlockNode.d.ts +429 -0
  17. package/dist/ast/BlockNode.d.ts.map +1 -0
  18. package/dist/ast/BlockNode.js +279 -0
  19. package/dist/ast/BlockNode.js.map +1 -0
  20. package/dist/ast/Document.d.ts +255 -0
  21. package/dist/ast/Document.d.ts.map +1 -0
  22. package/dist/ast/Document.js +80 -0
  23. package/dist/ast/Document.js.map +1 -0
  24. package/dist/ast/InlineNode.d.ts +483 -0
  25. package/dist/ast/InlineNode.d.ts.map +1 -0
  26. package/dist/ast/InlineNode.js +268 -0
  27. package/dist/ast/InlineNode.js.map +1 -0
  28. package/dist/ast/MacroNode.d.ts +214 -0
  29. package/dist/ast/MacroNode.d.ts.map +1 -0
  30. package/dist/ast/MacroNode.js +110 -0
  31. package/dist/ast/MacroNode.js.map +1 -0
  32. package/dist/ast/index.d.ts +10 -0
  33. package/dist/ast/index.d.ts.map +1 -0
  34. package/dist/ast/index.js +14 -0
  35. package/dist/ast/index.js.map +1 -0
  36. package/dist/auth/OAuthEndpoints.d.ts +95 -0
  37. package/dist/auth/OAuthEndpoints.d.ts.map +1 -0
  38. package/dist/auth/OAuthEndpoints.js +112 -0
  39. package/dist/auth/OAuthEndpoints.js.map +1 -0
  40. package/dist/auth/OAuthErrors.d.ts +76 -0
  41. package/dist/auth/OAuthErrors.d.ts.map +1 -0
  42. package/dist/auth/OAuthErrors.js +85 -0
  43. package/dist/auth/OAuthErrors.js.map +1 -0
  44. package/dist/auth/OAuthOperations.d.ts +87 -0
  45. package/dist/auth/OAuthOperations.d.ts.map +1 -0
  46. package/dist/auth/OAuthOperations.js +169 -0
  47. package/dist/auth/OAuthOperations.js.map +1 -0
  48. package/dist/auth/OAuthResponseSchemas.d.ts +65 -0
  49. package/dist/auth/OAuthResponseSchemas.d.ts.map +1 -0
  50. package/dist/auth/OAuthResponseSchemas.js +47 -0
  51. package/dist/auth/OAuthResponseSchemas.js.map +1 -0
  52. package/dist/auth/index.d.ts +11 -0
  53. package/dist/auth/index.d.ts.map +1 -0
  54. package/dist/auth/index.js +16 -0
  55. package/dist/auth/index.js.map +1 -0
  56. package/dist/auth/uuid.d.ts +14 -0
  57. package/dist/auth/uuid.d.ts.map +1 -0
  58. package/dist/auth/uuid.js +14 -0
  59. package/dist/auth/uuid.js.map +1 -0
  60. package/dist/config/ConfigPaths.d.ts +95 -0
  61. package/dist/config/ConfigPaths.d.ts.map +1 -0
  62. package/dist/config/ConfigPaths.js +102 -0
  63. package/dist/config/ConfigPaths.js.map +1 -0
  64. package/dist/config/OAuthSchemas.d.ts +144 -0
  65. package/dist/config/OAuthSchemas.d.ts.map +1 -0
  66. package/dist/config/OAuthSchemas.js +107 -0
  67. package/dist/config/OAuthSchemas.js.map +1 -0
  68. package/dist/config/TokenStorage.d.ts +96 -0
  69. package/dist/config/TokenStorage.d.ts.map +1 -0
  70. package/dist/config/TokenStorage.js +128 -0
  71. package/dist/config/TokenStorage.js.map +1 -0
  72. package/dist/config/index.d.ts +9 -0
  73. package/dist/config/index.d.ts.map +1 -0
  74. package/dist/config/index.js +12 -0
  75. package/dist/config/index.js.map +1 -0
  76. package/dist/index.d.ts +13 -0
  77. package/dist/index.d.ts.map +1 -0
  78. package/dist/index.js +20 -0
  79. package/dist/index.js.map +1 -0
  80. package/dist/parsers/index.d.ts +7 -0
  81. package/dist/parsers/index.d.ts.map +1 -0
  82. package/dist/parsers/index.js +8 -0
  83. package/dist/parsers/index.js.map +1 -0
  84. package/dist/serializers/MarkdownSerializer.d.ts +63 -0
  85. package/dist/serializers/MarkdownSerializer.d.ts.map +1 -0
  86. package/dist/serializers/MarkdownSerializer.js +367 -0
  87. package/dist/serializers/MarkdownSerializer.js.map +1 -0
  88. package/dist/serializers/index.d.ts +7 -0
  89. package/dist/serializers/index.d.ts.map +1 -0
  90. package/dist/serializers/index.js +7 -0
  91. package/dist/serializers/index.js.map +1 -0
  92. package/package.json +86 -0
  93. package/src/Brand.ts +142 -0
  94. package/src/Hash.ts +68 -0
  95. package/src/SerializeError.ts +50 -0
  96. package/src/ast/BlockNode.ts +386 -0
  97. package/src/ast/Document.ts +101 -0
  98. package/src/ast/InlineNode.ts +328 -0
  99. package/src/ast/MacroNode.ts +172 -0
  100. package/src/ast/index.ts +87 -0
  101. package/src/auth/OAuthEndpoints.ts +142 -0
  102. package/src/auth/OAuthErrors.ts +101 -0
  103. package/src/auth/OAuthOperations.ts +276 -0
  104. package/src/auth/OAuthResponseSchemas.ts +70 -0
  105. package/src/auth/index.ts +47 -0
  106. package/src/auth/uuid.ts +14 -0
  107. package/src/config/ConfigPaths.ts +179 -0
  108. package/src/config/OAuthSchemas.ts +146 -0
  109. package/src/config/TokenStorage.ts +228 -0
  110. package/src/config/index.ts +43 -0
  111. package/src/index.ts +34 -0
  112. package/src/parsers/index.ts +8 -0
  113. package/src/serializers/MarkdownSerializer.ts +498 -0
  114. package/src/serializers/index.ts +7 -0
  115. package/test/Brand.test.ts +90 -0
  116. package/test/MarkdownSerializer.test.ts +82 -0
  117. package/test/OAuthEndpoints.test.ts +109 -0
  118. package/test/OAuthOperations.test.ts +315 -0
  119. package/tsconfig.json +11 -0
  120. package/tsconfig.tsbuildinfo +1 -0
  121. package/vitest.config.ts +12 -0
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Persistent token and OAuth config storage with schema validation and secure file I/O.
3
+ *
4
+ * **Mental model**
5
+ *
6
+ * - **Load returns null, not error**: {@link loadToken} and {@link loadOAuthConfig} return
7
+ * `null` for missing/corrupt files — callers decide whether absence is an error.
8
+ * - **Save is atomic**: Writes go through {@link writeSecureFile} with `0o600` permissions.
9
+ * - **Schema-gated reads**: JSON is parsed then validated via `Schema.decodeUnknown` —
10
+ * corrupt data is treated as absent rather than crashing.
11
+ *
12
+ * **Common tasks**
13
+ *
14
+ * - Load stored token: {@link loadToken}
15
+ * - Persist after refresh: {@link saveToken}
16
+ * - Check expiration: {@link isTokenExpired}
17
+ *
18
+ * @module
19
+ */
20
+ import type * as Error from "@effect/platform/Error";
21
+ import * as FileSystem from "@effect/platform/FileSystem";
22
+ import type * as Path from "@effect/platform/Path";
23
+ import * as Effect from "effect/Effect";
24
+ import { type HomeDirectoryError, type HomeDirectoryTag } from "./ConfigPaths.js";
25
+ import { type OAuthConfig, type OAuthToken } from "./OAuthSchemas.js";
26
+ declare const FileSystemError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
27
+ readonly _tag: "FileSystemError";
28
+ } & Readonly<A>;
29
+ /**
30
+ * Error during file system operations.
31
+ *
32
+ * @category Errors
33
+ */
34
+ export declare class FileSystemError extends FileSystemError_base<{
35
+ readonly operation: string;
36
+ readonly path: string;
37
+ readonly cause?: unknown;
38
+ }> {
39
+ get message(): string;
40
+ }
41
+ /**
42
+ * Load stored OAuth token from disk.
43
+ *
44
+ * @param toolName - The tool name (e.g., "confluence", "jira")
45
+ * @returns The stored token or null if not found/invalid
46
+ *
47
+ * @category Token Storage
48
+ */
49
+ export declare const loadToken: (toolName: string) => Effect.Effect<OAuthToken | null, FileSystemError | HomeDirectoryError, FileSystem.FileSystem | Path.Path | HomeDirectoryTag>;
50
+ /**
51
+ * Save OAuth token to disk with secure permissions.
52
+ *
53
+ * @param toolName - The tool name (e.g., "confluence", "jira")
54
+ * @param token - The token to save
55
+ *
56
+ * @category Token Storage
57
+ */
58
+ export declare const saveToken: (toolName: string, token: OAuthToken) => Effect.Effect<void, FileSystemError | HomeDirectoryError | Error.PlatformError, FileSystem.FileSystem | Path.Path | HomeDirectoryTag>;
59
+ /**
60
+ * Delete stored OAuth token.
61
+ *
62
+ * @param toolName - The tool name (e.g., "confluence", "jira")
63
+ *
64
+ * @category Token Storage
65
+ */
66
+ export declare const deleteToken: (toolName: string) => Effect.Effect<void, FileSystemError | HomeDirectoryError, FileSystem.FileSystem | Path.Path | HomeDirectoryTag>;
67
+ /**
68
+ * Load OAuth client configuration from disk.
69
+ *
70
+ * @param toolName - The tool name (e.g., "confluence", "jira")
71
+ * @returns The stored config or null if not found/invalid
72
+ *
73
+ * @category OAuth Config
74
+ */
75
+ export declare const loadOAuthConfig: (toolName: string) => Effect.Effect<OAuthConfig | null, FileSystemError | HomeDirectoryError, FileSystem.FileSystem | Path.Path | HomeDirectoryTag>;
76
+ /**
77
+ * Save OAuth client configuration to disk with secure permissions.
78
+ *
79
+ * @param toolName - The tool name (e.g., "confluence", "jira")
80
+ * @param config - The config to save
81
+ *
82
+ * @category OAuth Config
83
+ */
84
+ export declare const saveOAuthConfig: (toolName: string, config: OAuthConfig) => Effect.Effect<void, FileSystemError | HomeDirectoryError | Error.PlatformError, FileSystem.FileSystem | Path.Path | HomeDirectoryTag>;
85
+ /**
86
+ * Check if token is expired or about to expire.
87
+ *
88
+ * @param token - The token to check
89
+ * @param bufferMs - Buffer time in ms before expiration (default: 5 minutes)
90
+ * @returns True if token is expired or will expire within buffer time
91
+ *
92
+ * @category Utilities
93
+ */
94
+ export declare const isTokenExpired: (token: OAuthToken, bufferMs?: number) => boolean;
95
+ export {};
96
+ //# sourceMappingURL=TokenStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TokenStor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eAAe,GAAG,kBAAkB,EAAE,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAQ7G,CAAA;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,KACf,MAAM,CAAC,MAAM,CACd,WAAW,GAAG,IAAI,EAClB,eAAe,GAAG,kBAAkB,EACpC,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAoClD,CAAA;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,EAChB,QAAQ,WAAW,KAClB,MAAM,CAAC,MAAM,CACd,IAAI,EACJ,eAAe,GAAG,kBAAkB,GAAG,KAAK,CAAC,aAAa,EAC1D,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAUlD,CAAA;AAEJ;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,UAAU,EAAE,WAAU,MAAsB,KAAG,OAC1C,CAAA"}
@@ -0,0 +1,128 @@
1
+ import * as FileSystem from "@effect/platform/FileSystem";
2
+ import * as Data from "effect/Data";
3
+ import * as Effect from "effect/Effect";
4
+ import * as Schema from "effect/Schema";
5
+ import {} from "./ConfigPaths.js";
6
+ import { ensureConfigDir, getAuthPath, getOAuthConfigPath, writeSecureFile } from "./ConfigPaths.js";
7
+ import { OAuthConfigSchema, OAuthTokenSchema } from "./OAuthSchemas.js";
8
+ /**
9
+ * Error during file system operations.
10
+ *
11
+ * @category Errors
12
+ */
13
+ export class FileSystemError extends Data.TaggedError("FileSystemError") {
14
+ get message() {
15
+ return `Failed to ${this.operation} file at ${this.path}`;
16
+ }
17
+ }
18
+ /**
19
+ * Load stored OAuth token from disk.
20
+ *
21
+ * @param toolName - The tool name (e.g., "confluence", "jira")
22
+ * @returns The stored token or null if not found/invalid
23
+ *
24
+ * @category Token Storage
25
+ */
26
+ export const loadToken = (toolName) => Effect.gen(function* () {
27
+ const fs = yield* FileSystem.FileSystem;
28
+ const tokenPath = yield* getAuthPath(toolName);
29
+ const exists = yield* fs.exists(tokenPath).pipe(Effect.catchAll(() => Effect.succeed(false)));
30
+ if (!exists) {
31
+ return null;
32
+ }
33
+ const content = yield* fs.readFileString(tokenPath).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "read", path: tokenPath, cause })));
34
+ const parsed = yield* Effect.sync(() => {
35
+ try {
36
+ return JSON.parse(content);
37
+ }
38
+ catch {
39
+ return null;
40
+ }
41
+ });
42
+ if (parsed === null) {
43
+ yield* Effect.logWarning(`Corrupted auth.json at ${tokenPath} — could not parse JSON`);
44
+ return null;
45
+ }
46
+ return yield* Schema.decodeUnknown(OAuthTokenSchema)(parsed).pipe(Effect.catchAll((e) => Effect.logWarning(`Invalid token schema in ${tokenPath}: ${e}`).pipe(Effect.map(() => null))));
47
+ });
48
+ /**
49
+ * Save OAuth token to disk with secure permissions.
50
+ *
51
+ * @param toolName - The tool name (e.g., "confluence", "jira")
52
+ * @param token - The token to save
53
+ *
54
+ * @category Token Storage
55
+ */
56
+ export const saveToken = (toolName, token) => Effect.gen(function* () {
57
+ const fs = yield* FileSystem.FileSystem;
58
+ yield* ensureConfigDir(toolName);
59
+ const tokenPath = yield* getAuthPath(toolName);
60
+ yield* writeSecureFile(tokenPath, JSON.stringify(token, null, 2)).pipe(Effect.provideService(FileSystem.FileSystem, fs));
61
+ });
62
+ /**
63
+ * Delete stored OAuth token.
64
+ *
65
+ * @param toolName - The tool name (e.g., "confluence", "jira")
66
+ *
67
+ * @category Token Storage
68
+ */
69
+ export const deleteToken = (toolName) => Effect.gen(function* () {
70
+ const fs = yield* FileSystem.FileSystem;
71
+ const tokenPath = yield* getAuthPath(toolName);
72
+ yield* fs.remove(tokenPath).pipe(Effect.catchAll(() => Effect.void));
73
+ });
74
+ /**
75
+ * Load OAuth client configuration from disk.
76
+ *
77
+ * @param toolName - The tool name (e.g., "confluence", "jira")
78
+ * @returns The stored config or null if not found/invalid
79
+ *
80
+ * @category OAuth Config
81
+ */
82
+ export const loadOAuthConfig = (toolName) => Effect.gen(function* () {
83
+ const fs = yield* FileSystem.FileSystem;
84
+ const configPath = yield* getOAuthConfigPath(toolName);
85
+ const exists = yield* fs.exists(configPath).pipe(Effect.catchAll(() => Effect.succeed(false)));
86
+ if (!exists) {
87
+ return null;
88
+ }
89
+ const content = yield* fs.readFileString(configPath).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "read", path: configPath, cause })));
90
+ const parsed = yield* Effect.sync(() => {
91
+ try {
92
+ return JSON.parse(content);
93
+ }
94
+ catch {
95
+ return null;
96
+ }
97
+ });
98
+ if (parsed === null) {
99
+ yield* Effect.logWarning(`Corrupted oauth config at ${configPath} — could not parse JSON`);
100
+ return null;
101
+ }
102
+ return yield* Schema.decodeUnknown(OAuthConfigSchema)(parsed).pipe(Effect.catchAll((e) => Effect.logWarning(`Invalid OAuth config schema in ${configPath}: ${e}`).pipe(Effect.map(() => null))));
103
+ });
104
+ /**
105
+ * Save OAuth client configuration to disk with secure permissions.
106
+ *
107
+ * @param toolName - The tool name (e.g., "confluence", "jira")
108
+ * @param config - The config to save
109
+ *
110
+ * @category OAuth Config
111
+ */
112
+ export const saveOAuthConfig = (toolName, config) => Effect.gen(function* () {
113
+ const fs = yield* FileSystem.FileSystem;
114
+ yield* ensureConfigDir(toolName);
115
+ const configPath = yield* getOAuthConfigPath(toolName);
116
+ yield* writeSecureFile(configPath, JSON.stringify(config, null, 2)).pipe(Effect.provideService(FileSystem.FileSystem, fs));
117
+ });
118
+ /**
119
+ * Check if token is expired or about to expire.
120
+ *
121
+ * @param token - The token to check
122
+ * @param bufferMs - Buffer time in ms before expiration (default: 5 minutes)
123
+ * @returns True if token is expired or will expire within buffer time
124
+ *
125
+ * @category Utilities
126
+ */
127
+ export const isTokenExpired = (token, bufferMs = 5 * 60 * 1000) => Date.now() >= token.expires_at - bufferMs;
128
+ //# sourceMappingURL=TokenStorage.js.map
@@ -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AC,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;IAChC,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAA;IAEtD,KAAK,CAAC,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CACtE,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE,CAAC,CACjD,CAAA;AACH,CAAC,CAAC,CAAA;AAEJ;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAiB,EAAE,WAAmB,CAAC,GAAG,EAAE,GAAG,IAAI,EAAW,EAAE,CAC7F,IAAI,CAAC,GAAG,EAAE,IAAI,KAAK,CAAC,UAAU,GAAG,QAAQ,CAAA"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Barrel export for config path utilities, schemas, and token storage.
3
+ *
4
+ * @module
5
+ */
6
+ export { ensureConfigDir, getAuthPath, getConfigDir, getOAuthConfigPath, type HomeDirectory, HomeDirectoryError, HomeDirectoryLive, HomeDirectoryTag, writeSecureFile } from "./ConfigPaths.js";
7
+ export { type AtlassianSite, AtlassianSiteSchema, type AtlassianUser, AtlassianUserSchema, type OAuthConfig, OAuthConfigSchema, type OAuthToken, OAuthTokenSchema, type OAuthUser, OAuthUserSchema } from "./OAuthSchemas.js";
8
+ export { deleteToken, FileSystemError, isTokenExpired, loadOAuthConfig, loadToken, saveOAuthConfig, saveToken } from "./TokenStorage.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,eAAe,EACf,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,KAAK,aAAa,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAChB,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EACL,KAAK,aAAa,EAClB,mBAAmB,EACnB,KAAK,aAAa,EAClB,mBAAmB,EACnB,KAAK,WAAW,EAChB,iBAAiB,EACjB,KAAK,UAAU,EACf,gBAAgB,EAChB,KAAK,SAAS,EACd,eAAe,EAChB,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EACL,WAAW,EACX,eAAe,EACf,cAAc,EACd,eAAe,EACf,SAAS,EACT,eAAe,EACf,SAAS,EACV,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Barrel export for config path utilities, schemas, and token storage.
3
+ *
4
+ * @module
5
+ */
6
+ // Config paths
7
+ export { ensureConfigDir, getAuthPath, getConfigDir, getOAuthConfigPath, HomeDirectoryError, HomeDirectoryLive, HomeDirectoryTag, writeSecureFile } from "./ConfigPaths.js";
8
+ // OAuth schemas
9
+ export { AtlassianSiteSchema, AtlassianUserSchema, OAuthConfigSchema, OAuthTokenSchema, OAuthUserSchema } from "./OAuthSchemas.js";
10
+ // Token storage
11
+ export { deleteToken, FileSystemError, isTokenExpired, loadOAuthConfig, loadToken, saveOAuthConfig, saveToken } from "./TokenStorage.js";
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAe;AACf,OAAO,EACL,eAAe,EACf,WAAW,EACX,YAAY,EACZ,kBAAkB,EAElB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAChB,MAAM,kBAAkB,CAAA;AAEzB,gBAAgB;AAChB,OAAO,EAEL,mBAAmB,EAEnB,mBAAmB,EAEnB,iBAAiB,EAEjB,gBAAgB,EAEhB,eAAe,EAChB,MAAM,mBAAmB,CAAA;AAE1B,gBAAgB;AAChB,OAAO,EACL,WAAW,EACX,eAAe,EACf,cAAc,EACd,eAAe,EACf,SAAS,EACT,eAAe,EACf,SAAS,EACV,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Root barrel export for `@knpkv/atlassian-common` — AST nodes, auth, config, serializers.
3
+ *
4
+ * @module
5
+ */
6
+ export * from "./ast/index.js";
7
+ export { ContentHash, IssueKey, makeBrandedNonEmptyString, makeBrandedString, PageId, ProjectKey, SpaceKey } from "./Brand.js";
8
+ export { hashBuffer, hashContent, hashContentSync, hashEquals } from "./Hash.js";
9
+ export { ParseError, SerializeError } from "./SerializeError.js";
10
+ export { serializeInlineNodes, type SerializeOptions, serializeToMarkdown } from "./serializers/index.js";
11
+ export * from "./config/index.js";
12
+ export * from "./auth/index.js";
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,gBAAgB,CAAA;AAG9B,OAAO,EACL,WAAW,EACX,QAAQ,EACR,yBAAyB,EACzB,iBAAiB,EACjB,MAAM,EACN,UAAU,EACV,QAAQ,EACT,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAGhF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAGhE,OAAO,EAAE,oBAAoB,EAAE,KAAK,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAGzG,cAAc,mBAAmB,CAAA;AAGjC,cAAc,iBAAiB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Root barrel export for `@knpkv/atlassian-common` — AST nodes, auth, config, serializers.
3
+ *
4
+ * @module
5
+ */
6
+ // AST types
7
+ export * from "./ast/index.js";
8
+ // Brand utilities
9
+ export { ContentHash, IssueKey, makeBrandedNonEmptyString, makeBrandedString, PageId, ProjectKey, SpaceKey } from "./Brand.js";
10
+ // Hash utilities
11
+ export { hashBuffer, hashContent, hashContentSync, hashEquals } from "./Hash.js";
12
+ // Error types
13
+ export { ParseError, SerializeError } from "./SerializeError.js";
14
+ // Serializers
15
+ export { serializeInlineNodes, serializeToMarkdown } from "./serializers/index.js";
16
+ // Config utilities
17
+ export * from "./config/index.js";
18
+ // Auth utilities
19
+ export * from "./auth/index.js";
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY;AACZ,cAAc,gBAAgB,CAAA;AAE9B,kBAAkB;AAClB,OAAO,EACL,WAAW,EACX,QAAQ,EACR,yBAAyB,EACzB,iBAAiB,EACjB,MAAM,EACN,UAAU,EACV,QAAQ,EACT,MAAM,YAAY,CAAA;AAEnB,iBAAiB;AACjB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEhF,cAAc;AACd,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEhE,cAAc;AACd,OAAO,EAAE,oBAAoB,EAAyB,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAEzG,mBAAmB;AACnB,cAAc,mBAAmB,CAAA;AAEjC,iBAAiB;AACjB,cAAc,iBAAiB,CAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Barrel export for content parsers (placeholder — not yet implemented).
3
+ *
4
+ * @module
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parsers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,CAAA"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Barrel export for content parsers (placeholder — not yet implemented).
3
+ *
4
+ * @module
5
+ */
6
+ // TODO: Extract MarkdownParser from confluence-to-markdown
7
+ export {};
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parsers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,2DAA2D;AAC3D,OAAO,EAAE,CAAA"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * AST-to-Markdown serializer with roundtrip comment encoding for non-Markdown features.
3
+ *
4
+ * **Mental model**
5
+ *
6
+ * - **Visitor over DocumentNode union**: {@link serializeToMarkdown} walks the AST, dispatching
7
+ * on `_tag` to emit Markdown. Effect-based for composability with the rest of the pipeline.
8
+ * - **Roundtrip via HTML comments**: Confluence-specific data (panel types, task status,
9
+ * image alignment) is encoded in `<!-- ... -->` comments with base64/URL encoding so
10
+ * a future parser can reconstruct the original.
11
+ *
12
+ * **Common tasks**
13
+ *
14
+ * - Serialize a document: {@link serializeToMarkdown}
15
+ * - Serialize inline nodes only: {@link serializeInlineNodes}
16
+ *
17
+ * **Gotchas**
18
+ *
19
+ * - Comment-encoded data is fragile if users hand-edit the Markdown — edits inside
20
+ * `<!-- -->` blocks will break roundtripping.
21
+ *
22
+ * @module
23
+ */
24
+ import * as Effect from "effect/Effect";
25
+ import type { Document } from "../ast/Document.js";
26
+ import type { InlineNode } from "../ast/InlineNode.js";
27
+ import type { SerializeError } from "../SerializeError.js";
28
+ /**
29
+ * Options for Markdown serialization.
30
+ *
31
+ * @category Serializers
32
+ */
33
+ export interface SerializeOptions {
34
+ /** Include raw source for lossless roundtrip. Default: false */
35
+ readonly includeRawSource?: boolean;
36
+ /** Custom comment prefix for roundtrip encoding. Default: "src" */
37
+ readonly commentPrefix?: string;
38
+ }
39
+ /**
40
+ * Serialize Document AST to GitHub Flavored Markdown.
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * import { serializeToMarkdown, makeDocument, Heading, Text } from "@knpkv/atlassian-common"
45
+ * import { Effect } from "effect"
46
+ *
47
+ * Effect.gen(function* () {
48
+ * const doc = makeDocument([
49
+ * new Heading({ level: 1, children: [new Text({ value: "Title" })] })
50
+ * ])
51
+ * const md = yield* serializeToMarkdown(doc)
52
+ * console.log(md) // # Title
53
+ * })
54
+ * ```
55
+ *
56
+ * @category Serializers
57
+ */
58
+ export declare const serializeToMarkdown: (doc: Document, options?: SerializeOptions) => Effect.Effect<string, SerializeError>;
59
+ /**
60
+ * Serialize inline nodes to Markdown.
61
+ */
62
+ export declare const serializeInlineNodes: (nodes: ReadonlyArray<InlineNode>) => Effect.Effect<string, SerializeError>;
63
+ //# sourceMappingURL=MarkdownSerializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownSerializer.d.ts","sourceRoot":"","sources":["../../src/serializers/MarkdownSerializer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAgB,MAAM,oBAAoB,CAAA;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,gEAAgE;IAChE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;IACnC,mEAAmE;IACnE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAChC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,mBAAmB,GAC9B,KAAK,QAAQ,EACb,UAAS,gBAAqB,KAC7B,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAkBnC,CAAA;AAuVJ;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAC/B,OAAO,aAAa,CAAC,UAAU,CAAC,KAC/B,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAOnC,CAAA"}