@knpkv/atlassian-common 0.4.0 → 1.1.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 (73) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +4 -3
  3. package/dist/Brand.d.ts.map +1 -1
  4. package/dist/Brand.js +4 -2
  5. package/dist/Brand.js.map +1 -1
  6. package/dist/Hash.d.ts +4 -4
  7. package/dist/Hash.js +6 -6
  8. package/dist/Hash.js.map +1 -1
  9. package/dist/ast/Document.d.ts +2 -2
  10. package/dist/ast/Document.d.ts.map +1 -1
  11. package/dist/ast/Document.js +1 -1
  12. package/dist/ast/Document.js.map +1 -1
  13. package/dist/ast/MacroNode.d.ts +4 -4
  14. package/dist/ast/MacroNode.d.ts.map +1 -1
  15. package/dist/ast/MacroNode.js +8 -1
  16. package/dist/ast/MacroNode.js.map +1 -1
  17. package/dist/attachments.d.ts +42 -0
  18. package/dist/attachments.d.ts.map +1 -0
  19. package/dist/attachments.js +51 -0
  20. package/dist/attachments.js.map +1 -0
  21. package/dist/auth/OAuthEndpoints.d.ts +6 -4
  22. package/dist/auth/OAuthEndpoints.d.ts.map +1 -1
  23. package/dist/auth/OAuthEndpoints.js +14 -7
  24. package/dist/auth/OAuthEndpoints.js.map +1 -1
  25. package/dist/auth/OAuthErrors.d.ts.map +1 -1
  26. package/dist/auth/OAuthErrors.js +4 -3
  27. package/dist/auth/OAuthErrors.js.map +1 -1
  28. package/dist/auth/OAuthOperations.d.ts +0 -20
  29. package/dist/auth/OAuthOperations.d.ts.map +1 -1
  30. package/dist/auth/OAuthOperations.js +3 -1
  31. package/dist/auth/OAuthOperations.js.map +1 -1
  32. package/dist/auth/uuid.d.ts +5 -3
  33. package/dist/auth/uuid.d.ts.map +1 -1
  34. package/dist/auth/uuid.js +7 -3
  35. package/dist/auth/uuid.js.map +1 -1
  36. package/dist/bin.js +1 -1
  37. package/dist/bin.js.map +1 -1
  38. package/dist/config/AuthProfiles.js.map +1 -1
  39. package/dist/config/ProfileManager.d.ts +3 -20
  40. package/dist/config/ProfileManager.d.ts.map +1 -1
  41. package/dist/config/ProfileManager.js +2 -1
  42. package/dist/config/ProfileManager.js.map +1 -1
  43. package/dist/config/TokenStorage.js.map +1 -1
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +2 -0
  47. package/dist/index.js.map +1 -1
  48. package/dist/serializers/MarkdownSerializer.d.ts.map +1 -1
  49. package/dist/serializers/MarkdownSerializer.js +9 -6
  50. package/dist/serializers/MarkdownSerializer.js.map +1 -1
  51. package/package.json +12 -8
  52. package/src/Brand.ts +4 -2
  53. package/src/Hash.ts +6 -6
  54. package/src/ast/Document.ts +1 -1
  55. package/src/ast/MacroNode.ts +8 -1
  56. package/src/attachments.ts +98 -0
  57. package/src/auth/OAuthEndpoints.ts +20 -11
  58. package/src/auth/OAuthErrors.ts +4 -3
  59. package/src/auth/OAuthOperations.ts +3 -1
  60. package/src/auth/uuid.ts +9 -3
  61. package/src/bin.ts +1 -1
  62. package/src/config/AuthProfiles.ts +1 -1
  63. package/src/config/ProfileManager.ts +21 -9
  64. package/src/config/TokenStorage.ts +1 -1
  65. package/src/index.ts +3 -0
  66. package/src/serializers/MarkdownSerializer.ts +22 -37
  67. package/test/AuthProfiles.test.ts +1 -1
  68. package/test/OAuthEndpoints.test.ts +34 -16
  69. package/test/OAuthOperations.test.ts +5 -1
  70. package/test/ProfileManager.test.ts +1 -1
  71. package/test/attachments.test.ts +75 -0
  72. package/test/fixtures/attachments/inline-attachment.svg +6 -0
  73. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,75 @@
1
+ import { describe, expect, it } from "vitest"
2
+ import { isPreviewableAttachment, renderAttachmentMarkdown, replaceAttachmentPlaceholder } from "../src/attachments.js"
3
+
4
+ describe("attachment helpers", () => {
5
+ it("treats SVG as previewable even with a generic media type", () => {
6
+ expect(isPreviewableAttachment({
7
+ filename: "diagram.svg",
8
+ mediaType: "application/octet-stream"
9
+ })).toBe(true)
10
+ })
11
+
12
+ it("renders image attachments as previews and other attachments as links", () => {
13
+ expect(renderAttachmentMarkdown({
14
+ id: "1",
15
+ filename: "screenshot.png",
16
+ url: "https://example.test/screenshot.png",
17
+ mediaType: "image/png",
18
+ size: 1
19
+ })).toBe("![screenshot.png](https://example.test/screenshot.png)")
20
+
21
+ expect(renderAttachmentMarkdown({
22
+ id: "2",
23
+ filename: "debug.log",
24
+ url: "https://example.test/debug.log",
25
+ mediaType: "text/plain",
26
+ size: 1
27
+ })).toBe("[debug.log](https://example.test/debug.log)")
28
+ })
29
+
30
+ it("escapes labels and wraps unsafe destinations in rendered markdown", () => {
31
+ expect(renderAttachmentMarkdown({
32
+ id: "1",
33
+ filename: "weird ] name\n.svg",
34
+ url: "https://example.test/a file(1).svg",
35
+ mediaType: "image/svg+xml",
36
+ size: 1
37
+ })).toBe("![weird \\] name .svg](<https://example.test/a file(1).svg>)")
38
+ })
39
+
40
+ it("uses an explicit label when rendering attachment markdown", () => {
41
+ expect(renderAttachmentMarkdown({
42
+ id: "1",
43
+ filename: "diagram.svg",
44
+ url: "https://example.test/diagram.svg",
45
+ mediaType: "image/svg+xml",
46
+ size: 1
47
+ }, { label: "Architecture diagram" })).toBe("![Architecture diagram](https://example.test/diagram.svg)")
48
+ })
49
+
50
+ it("replaces a named local Markdown placeholder", () => {
51
+ const result = replaceAttachmentPlaceholder(
52
+ "before\n![Diagram](./diagram.svg)\nafter",
53
+ "./diagram.svg",
54
+ "![diagram.svg](https://example.test/diagram.svg)"
55
+ )
56
+
57
+ expect(result).toEqual({
58
+ replacements: 1,
59
+ content: "before\n![diagram.svg](https://example.test/diagram.svg)\nafter"
60
+ })
61
+ })
62
+
63
+ it("passes the placeholder label to callback replacements", () => {
64
+ const result = replaceAttachmentPlaceholder(
65
+ "before\n![Architecture diagram](./diagram.svg)\nafter",
66
+ "./diagram.svg",
67
+ ({ isImage, label }) => `${isImage ? "!" : ""}[${label}](https://example.test/diagram.svg)`
68
+ )
69
+
70
+ expect(result).toEqual({
71
+ replacements: 1,
72
+ content: "before\n![Architecture diagram](https://example.test/diagram.svg)\nafter"
73
+ })
74
+ })
75
+ })
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="160" height="80" viewBox="0 0 160 80" role="img" aria-label="Inline attachment test asset">
2
+ <rect width="160" height="80" fill="#f4f7fb"/>
3
+ <rect x="12" y="12" width="136" height="56" rx="6" fill="#ffffff" stroke="#2f6fed" stroke-width="3"/>
4
+ <circle cx="40" cy="40" r="13" fill="#ffb000"/>
5
+ <path d="M66 51h58M66 39h72M66 28h44" stroke="#243b53" stroke-width="6" stroke-linecap="round"/>
6
+ </svg>