@repo-toolkit/confluence 0.8.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/LICENSE +201 -0
- package/README.md +95 -0
- package/cli.js +870 -0
- package/index.d.ts +179 -0
- package/index.js +781 -0
- package/package.json +46 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { FlagSpec } from '@repo-toolkit/publish-package';
|
|
2
|
+
export { FlagSpec, isPlainObject, parseFlags, resolveCliOptions } from '@repo-toolkit/publish-package';
|
|
3
|
+
|
|
4
|
+
interface ConfluenceClientOptions {
|
|
5
|
+
baseUrl: string;
|
|
6
|
+
username: string;
|
|
7
|
+
apiToken: string;
|
|
8
|
+
fetch?: typeof fetch;
|
|
9
|
+
userAgent?: string;
|
|
10
|
+
}
|
|
11
|
+
interface PageBody {
|
|
12
|
+
representation: 'storage' | 'atlas_doc' | 'wiki' | 'view' | 'export_view';
|
|
13
|
+
value: string;
|
|
14
|
+
}
|
|
15
|
+
interface PageVersion {
|
|
16
|
+
number: number;
|
|
17
|
+
message?: string;
|
|
18
|
+
}
|
|
19
|
+
interface CreatePageInput {
|
|
20
|
+
spaceId: string;
|
|
21
|
+
title: string;
|
|
22
|
+
body: PageBody;
|
|
23
|
+
parentId?: string;
|
|
24
|
+
status?: 'current' | 'draft';
|
|
25
|
+
}
|
|
26
|
+
interface UpdatePageInput {
|
|
27
|
+
id: string;
|
|
28
|
+
title: string;
|
|
29
|
+
body: PageBody;
|
|
30
|
+
version: PageVersion;
|
|
31
|
+
status?: 'current' | 'draft';
|
|
32
|
+
}
|
|
33
|
+
interface Page {
|
|
34
|
+
id: string;
|
|
35
|
+
status: string;
|
|
36
|
+
title: string;
|
|
37
|
+
spaceId: string;
|
|
38
|
+
parentId?: string;
|
|
39
|
+
body?: {
|
|
40
|
+
storage?: {
|
|
41
|
+
value: string;
|
|
42
|
+
representation: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
version: {
|
|
46
|
+
number: number;
|
|
47
|
+
createdAt?: string;
|
|
48
|
+
message?: string;
|
|
49
|
+
};
|
|
50
|
+
_links: {
|
|
51
|
+
webui: string;
|
|
52
|
+
self?: string;
|
|
53
|
+
base?: string;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
interface Attachment {
|
|
57
|
+
id: string;
|
|
58
|
+
title: string;
|
|
59
|
+
filename?: string;
|
|
60
|
+
mediaType?: string;
|
|
61
|
+
fileSize?: number;
|
|
62
|
+
pageId?: string;
|
|
63
|
+
spaceId?: string;
|
|
64
|
+
version: {
|
|
65
|
+
number: number;
|
|
66
|
+
createdAt?: string;
|
|
67
|
+
message?: string;
|
|
68
|
+
};
|
|
69
|
+
_links: {
|
|
70
|
+
webui: string;
|
|
71
|
+
download?: string;
|
|
72
|
+
self?: string;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
declare class ConfluenceApiError extends Error {
|
|
76
|
+
readonly status: number;
|
|
77
|
+
readonly endpoint: string;
|
|
78
|
+
readonly responseBody: string;
|
|
79
|
+
constructor(message: string, status: number, endpoint: string, responseBody: string);
|
|
80
|
+
}
|
|
81
|
+
declare class ConfluenceClient {
|
|
82
|
+
private readonly baseUrl;
|
|
83
|
+
private readonly authHeader;
|
|
84
|
+
private readonly fetchFn;
|
|
85
|
+
private readonly userAgent;
|
|
86
|
+
constructor(options: ConfluenceClientOptions);
|
|
87
|
+
getSpaceIdByKey(spaceKey: string): Promise<string>;
|
|
88
|
+
getPageByTitle(spaceId: string, title: string): Promise<Page | undefined>;
|
|
89
|
+
getPage(pageId: string): Promise<Page>;
|
|
90
|
+
createPage(input: CreatePageInput): Promise<Page>;
|
|
91
|
+
updatePage(input: UpdatePageInput): Promise<Page>;
|
|
92
|
+
getAttachments(pageId: string): Promise<Attachment[]>;
|
|
93
|
+
uploadAttachment(pageId: string, filePath: string, comment?: string): Promise<Attachment>;
|
|
94
|
+
updateAttachmentData(pageId: string, attachmentId: string, filePath: string, comment?: string): Promise<Attachment>;
|
|
95
|
+
private sendAttachmentMultipart;
|
|
96
|
+
private requestJson;
|
|
97
|
+
private v2Url;
|
|
98
|
+
private v1Url;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface DocEntry {
|
|
102
|
+
/** Path segments relative to the root, e.g. ['guide', 'intro.md']. Always uses `/` separators. */
|
|
103
|
+
segments: string[];
|
|
104
|
+
/** Absolute path to the file on disk. */
|
|
105
|
+
absolute: string;
|
|
106
|
+
}
|
|
107
|
+
interface DocTree {
|
|
108
|
+
entries: DocEntry[];
|
|
109
|
+
}
|
|
110
|
+
declare function readDocTree(root: string, depth?: number): Promise<DocTree>;
|
|
111
|
+
declare function isMarkdownName(name: string): boolean;
|
|
112
|
+
declare function titleFromSegment(segment: string): string;
|
|
113
|
+
|
|
114
|
+
interface MarkdownConvertResult {
|
|
115
|
+
html: string;
|
|
116
|
+
}
|
|
117
|
+
declare function markdownToStorage(markdown: string): MarkdownConvertResult;
|
|
118
|
+
declare function renderInline(text: string): string;
|
|
119
|
+
declare const LOCAL_IMAGE_PLACEHOLDER_RE: RegExp;
|
|
120
|
+
declare function isRemoteUrl(src: string): boolean;
|
|
121
|
+
declare function escapeXmlAttribute(text: string): string;
|
|
122
|
+
declare function escapeAttachmentFilename(filename: string): string;
|
|
123
|
+
|
|
124
|
+
interface RewriteResult {
|
|
125
|
+
html: string;
|
|
126
|
+
uploaded: ReadonlyArray<{
|
|
127
|
+
src: string;
|
|
128
|
+
attachment: Attachment;
|
|
129
|
+
}>;
|
|
130
|
+
}
|
|
131
|
+
interface RewriteOptions {
|
|
132
|
+
/** Directory used to resolve relative image src values. The markdown file's own dir. */
|
|
133
|
+
markdownDir: string;
|
|
134
|
+
}
|
|
135
|
+
declare function rewriteImagesToAttachments(html: string, pageId: string, client: ConfluenceClient, options: RewriteOptions): Promise<RewriteResult>;
|
|
136
|
+
|
|
137
|
+
declare const INTERACTIVE_FLAG: FlagSpec;
|
|
138
|
+
interface ConfluenceSyncOptions {
|
|
139
|
+
/** Documentation root folder (relative to `cwd`, or absolute). Required. */
|
|
140
|
+
folder?: string;
|
|
141
|
+
/** Confluence username or email. Required. */
|
|
142
|
+
username?: string;
|
|
143
|
+
/** Confluence API token (NOT account password). Required. */
|
|
144
|
+
apiToken?: string;
|
|
145
|
+
/** Confluence base URL ending with `/wiki`, e.g. `https://mydomain.atlassian.net/wiki`. Required. */
|
|
146
|
+
baseUrl?: string;
|
|
147
|
+
/** Confluence space key (e.g. `ENG` or `~1234`). Required; resolved to a spaceId via the API. */
|
|
148
|
+
spaceKey?: string;
|
|
149
|
+
/** Numeric Confluence page id of the parent under which docs will be published. Required. */
|
|
150
|
+
parentPageId?: string;
|
|
151
|
+
/** Working directory. Defaults to `process.cwd()`. */
|
|
152
|
+
cwd?: string;
|
|
153
|
+
/** Version-message suffix appended to every page/attachment PUT. */
|
|
154
|
+
versionMessage?: string;
|
|
155
|
+
/** Skip uploads that would have no markdown changes (default: true). */
|
|
156
|
+
skipUnchanged?: boolean;
|
|
157
|
+
/** Dry-run: walk the tree and print the plan but make no API calls. */
|
|
158
|
+
dryRun?: boolean;
|
|
159
|
+
/** Custom Confluence client instance (testing). When supplied, `username`/`apiToken`/`baseUrl` are ignored. */
|
|
160
|
+
client?: ConfluenceClient;
|
|
161
|
+
/** Logger sink; defaults to `console`. */
|
|
162
|
+
log?: (message: string) => void;
|
|
163
|
+
}
|
|
164
|
+
interface ConfluenceSyncPlan {
|
|
165
|
+
cwd: string;
|
|
166
|
+
folder: string;
|
|
167
|
+
username: string;
|
|
168
|
+
apiToken: string;
|
|
169
|
+
baseUrl: string;
|
|
170
|
+
spaceKey: string;
|
|
171
|
+
parentPageId: string;
|
|
172
|
+
versionMessage: string;
|
|
173
|
+
skipUnchanged: boolean;
|
|
174
|
+
dryRun: boolean;
|
|
175
|
+
}
|
|
176
|
+
declare function resolveConfluenceSyncPlan(options?: ConfluenceSyncOptions): ConfluenceSyncPlan;
|
|
177
|
+
declare function syncConfluenceToDocs(options?: ConfluenceSyncOptions): Promise<void>;
|
|
178
|
+
|
|
179
|
+
export { type Attachment, ConfluenceApiError, ConfluenceClient, type ConfluenceClientOptions, type ConfluenceSyncOptions, type ConfluenceSyncPlan, type DocEntry, type DocTree, INTERACTIVE_FLAG, LOCAL_IMAGE_PLACEHOLDER_RE, type Page, type PageBody, type PageVersion, escapeAttachmentFilename, escapeXmlAttribute, isMarkdownName, isRemoteUrl, markdownToStorage, readDocTree, renderInline, resolveConfluenceSyncPlan, resolveConfluenceSyncPlan as resolveSyncPlan, rewriteImagesToAttachments, syncConfluenceToDocs, titleFromSegment };
|