@superdurable/connector-atlassian-confluence 0.0.0-stage → 0.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.
- package/LICENSE +21 -0
- package/README.md +21 -2
- package/dex-connector.json +196 -0
- package/dist/chunk-OAQFTUZS.js +387 -0
- package/dist/connection-Pzxytl_b.d.ts +397 -0
- package/dist/index.d.ts +371 -0
- package/dist/index.js +2100 -0
- package/dist/mock.d.ts +145 -0
- package/dist/mock.js +354 -0
- package/package.json +62 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,2100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AddCommentBranch,
|
|
3
|
+
AddCommentBranchAdded,
|
|
4
|
+
AddCommentBranchDefect,
|
|
5
|
+
AddCommentBranchNotFound,
|
|
6
|
+
AddCommentBranchProviderRejected,
|
|
7
|
+
AddCommentBranchUncertain,
|
|
8
|
+
AddCommentDefinition,
|
|
9
|
+
AddCommentInputSchema,
|
|
10
|
+
AddCommentMetadata,
|
|
11
|
+
AddCommentOutputSchema,
|
|
12
|
+
ConfigSchema,
|
|
13
|
+
Connection,
|
|
14
|
+
ConnectorID,
|
|
15
|
+
CreatePageBranch,
|
|
16
|
+
CreatePageBranchCreated,
|
|
17
|
+
CreatePageBranchDefect,
|
|
18
|
+
CreatePageBranchNotFound,
|
|
19
|
+
CreatePageBranchProviderRejected,
|
|
20
|
+
CreatePageBranchTitleConflict,
|
|
21
|
+
CreatePageDefinition,
|
|
22
|
+
CreatePageInputSchema,
|
|
23
|
+
CreatePageMetadata,
|
|
24
|
+
CreatePageOutputSchema,
|
|
25
|
+
GetPageBranch,
|
|
26
|
+
GetPageBranchDefect,
|
|
27
|
+
GetPageBranchFound,
|
|
28
|
+
GetPageBranchInvalidResponse,
|
|
29
|
+
GetPageBranchNotFound,
|
|
30
|
+
GetPageBranchProviderRejected,
|
|
31
|
+
GetPageDefinition,
|
|
32
|
+
GetPageInputSchema,
|
|
33
|
+
GetPageMetadata,
|
|
34
|
+
PageSchema,
|
|
35
|
+
PageSearchFilterSchema,
|
|
36
|
+
PageSummarySchema,
|
|
37
|
+
PageVersionSchema,
|
|
38
|
+
ProviderID,
|
|
39
|
+
SearchPagesBranch,
|
|
40
|
+
SearchPagesBranchDefect,
|
|
41
|
+
SearchPagesBranchInvalidResponse,
|
|
42
|
+
SearchPagesBranchProviderRejected,
|
|
43
|
+
SearchPagesBranchSearched,
|
|
44
|
+
SearchPagesDefinition,
|
|
45
|
+
SearchPagesInputSchema,
|
|
46
|
+
SearchPagesMetadata,
|
|
47
|
+
SearchPagesOutputSchema,
|
|
48
|
+
UpdatePageBranch,
|
|
49
|
+
UpdatePageBranchDefect,
|
|
50
|
+
UpdatePageBranchNotFound,
|
|
51
|
+
UpdatePageBranchProviderRejected,
|
|
52
|
+
UpdatePageBranchUpdated,
|
|
53
|
+
UpdatePageBranchVersionConflict,
|
|
54
|
+
UpdatePageDefinition,
|
|
55
|
+
UpdatePageInputSchema,
|
|
56
|
+
UpdatePageMetadata,
|
|
57
|
+
UpdatePageOutputSchema,
|
|
58
|
+
decodeCredentials,
|
|
59
|
+
decodeSharedCredentials,
|
|
60
|
+
newConnection,
|
|
61
|
+
newConnectionWithOperations,
|
|
62
|
+
newProjectConnection,
|
|
63
|
+
newProjectCredentialProvider
|
|
64
|
+
} from "./chunk-OAQFTUZS.js";
|
|
65
|
+
|
|
66
|
+
// src/generated/steps.ts
|
|
67
|
+
import { goToBranch, newMutationStep, newQueryStep } from "@superdurable/connectors-sdk";
|
|
68
|
+
function newSearchPagesStep(configuration) {
|
|
69
|
+
const { connection, connectionName, searched, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
70
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
71
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.searchPages(), connection: connection.reference, branches: [
|
|
72
|
+
goToBranch("searched", searched),
|
|
73
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
74
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
75
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
76
|
+
] });
|
|
77
|
+
}
|
|
78
|
+
function newGetPageStep(configuration) {
|
|
79
|
+
const { connection, connectionName, found, notFound, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
|
|
80
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
81
|
+
return newQueryStep({ ...stepConfiguration, operation: connection.operations.getPage(), connection: connection.reference, branches: [
|
|
82
|
+
goToBranch("found", found),
|
|
83
|
+
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
84
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
85
|
+
...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
|
|
86
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
87
|
+
] });
|
|
88
|
+
}
|
|
89
|
+
function newCreatePageStep(configuration) {
|
|
90
|
+
const { connection, connectionName, created, titleConflict, notFound, providerRejected, defect, ...stepConfiguration } = configuration;
|
|
91
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
92
|
+
return newMutationStep({ ...stepConfiguration, operation: connection.operations.createPage(), connection: connection.reference, branches: [
|
|
93
|
+
goToBranch("created", created),
|
|
94
|
+
...titleConflict ? [goToBranch("titleConflict", titleConflict)] : [],
|
|
95
|
+
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
96
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
97
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
98
|
+
] });
|
|
99
|
+
}
|
|
100
|
+
function newUpdatePageStep(configuration) {
|
|
101
|
+
const { connection, connectionName, updated, versionConflict, notFound, providerRejected, defect, ...stepConfiguration } = configuration;
|
|
102
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
103
|
+
return newMutationStep({ ...stepConfiguration, operation: connection.operations.updatePage(), connection: connection.reference, branches: [
|
|
104
|
+
goToBranch("updated", updated),
|
|
105
|
+
...versionConflict ? [goToBranch("versionConflict", versionConflict)] : [],
|
|
106
|
+
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
107
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
108
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
109
|
+
] });
|
|
110
|
+
}
|
|
111
|
+
function newAddCommentStep(configuration) {
|
|
112
|
+
const { connection, connectionName, added, notFound, providerRejected, uncertain, defect, ...stepConfiguration } = configuration;
|
|
113
|
+
if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
|
|
114
|
+
return newMutationStep({ ...stepConfiguration, operation: connection.operations.addComment(), connection: connection.reference, branches: [
|
|
115
|
+
goToBranch("added", added),
|
|
116
|
+
...notFound ? [goToBranch("notFound", notFound)] : [],
|
|
117
|
+
...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
|
|
118
|
+
...uncertain ? [goToBranch("uncertain", uncertain)] : [],
|
|
119
|
+
...defect ? [goToBranch("defect", defect)] : []
|
|
120
|
+
] });
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// src/client.ts
|
|
124
|
+
import { BodyTooLargeError, ProviderTransportError, isHeaderSafeCredential, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
|
|
125
|
+
import { resolveCredential, resolveCredentialAfterRejection } from "@superdurable/connectors-sdk";
|
|
126
|
+
import { ManifestCredentialRefreshDriver } from "@superdurable/connectors-sdk/oauthtoken";
|
|
127
|
+
|
|
128
|
+
// src/generated/refresh.ts
|
|
129
|
+
var Authorization = {
|
|
130
|
+
"fields": [
|
|
131
|
+
{
|
|
132
|
+
"name": "oauth_client_id",
|
|
133
|
+
"required": true,
|
|
134
|
+
"type": "string"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"name": "oauth_client_secret",
|
|
138
|
+
"required": true,
|
|
139
|
+
"type": "secretString"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"name": "access_token",
|
|
143
|
+
"required": true,
|
|
144
|
+
"type": "secretString"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"name": "refresh_token",
|
|
148
|
+
"required": true,
|
|
149
|
+
"type": "secretString"
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
"oauth2": {
|
|
153
|
+
"clientIDCredential": "oauth_client_id",
|
|
154
|
+
"clientSecretCredential": "oauth_client_secret",
|
|
155
|
+
"credentialMappings": [
|
|
156
|
+
{
|
|
157
|
+
"credential": "access_token",
|
|
158
|
+
"source": "access_token"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"credential": "refresh_token",
|
|
162
|
+
"source": "refresh_token"
|
|
163
|
+
}
|
|
164
|
+
],
|
|
165
|
+
"refresh": {
|
|
166
|
+
"acceptedScopeSets": [
|
|
167
|
+
[
|
|
168
|
+
"search:confluence",
|
|
169
|
+
"read:page:confluence",
|
|
170
|
+
"write:page:confluence",
|
|
171
|
+
"read:space:confluence",
|
|
172
|
+
"read:comment:confluence",
|
|
173
|
+
"write:comment:confluence"
|
|
174
|
+
]
|
|
175
|
+
],
|
|
176
|
+
"acceptsMissingTokenType": true,
|
|
177
|
+
"missingExpiry": "reject",
|
|
178
|
+
"scopeSeparators": "whitespaceAndComma",
|
|
179
|
+
"storedMissingExpiry": "refresh",
|
|
180
|
+
"terminalErrorCodes": [
|
|
181
|
+
"invalid_grant",
|
|
182
|
+
"invalid_client",
|
|
183
|
+
"unauthorized_client"
|
|
184
|
+
]
|
|
185
|
+
},
|
|
186
|
+
"scopes": [
|
|
187
|
+
"search:confluence",
|
|
188
|
+
"read:page:confluence",
|
|
189
|
+
"write:page:confluence",
|
|
190
|
+
"read:space:confluence",
|
|
191
|
+
"read:comment:confluence",
|
|
192
|
+
"write:comment:confluence",
|
|
193
|
+
"offline_access"
|
|
194
|
+
],
|
|
195
|
+
"tokenEndpoint": "https://auth.atlassian.com/oauth/token",
|
|
196
|
+
"tokenRequestEncoding": "json"
|
|
197
|
+
},
|
|
198
|
+
"refreshable": true,
|
|
199
|
+
"type": "oauth2"
|
|
200
|
+
};
|
|
201
|
+
var CredentialFields = {
|
|
202
|
+
"access_token": "accessToken",
|
|
203
|
+
"oauth_client_id": "oauthClientId",
|
|
204
|
+
"oauth_client_secret": "oauthClientSecret",
|
|
205
|
+
"refresh_token": "refreshToken"
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// src/operations.ts
|
|
209
|
+
import { newMutationBranch, newMutationRetry, newMutationUncertain, newQueryBranch, newQueryRetry, zeroReceipt } from "@superdurable/connectors-sdk";
|
|
210
|
+
import { createHash } from "crypto";
|
|
211
|
+
|
|
212
|
+
// src/document.ts
|
|
213
|
+
function renderDocumentText(blocks, format, maxCharacters) {
|
|
214
|
+
const text = renderBlocks(blocks, format === "markdown").trim();
|
|
215
|
+
const characters = [...text];
|
|
216
|
+
return maxCharacters > 0 && characters.length > maxCharacters ? { text: characters.slice(0, maxCharacters).join(""), isTruncated: true } : { text, isTruncated: false };
|
|
217
|
+
}
|
|
218
|
+
function documentComparisonText(blocks) {
|
|
219
|
+
return renderBlocks(blocks, false).split(/\s+/u).join("");
|
|
220
|
+
}
|
|
221
|
+
function renderBlocks(blocks, isMarkdown) {
|
|
222
|
+
return blocks.map((block) => renderBlock(block, isMarkdown)).filter((value) => value.trim()).join("\n\n");
|
|
223
|
+
}
|
|
224
|
+
function renderBlock(block, isMarkdown) {
|
|
225
|
+
switch (block.kind) {
|
|
226
|
+
case "paragraph": {
|
|
227
|
+
const text = renderInlines(block.inlines || [], isMarkdown);
|
|
228
|
+
return isMarkdown ? text.split("\n").map(escapeMarkdownLineStart).join("\n") : text;
|
|
229
|
+
}
|
|
230
|
+
case "heading": {
|
|
231
|
+
const text = renderInlines(block.inlines || [], isMarkdown).replace(/\n/g, " ");
|
|
232
|
+
return isMarkdown ? "#".repeat(Math.min(6, Math.max(1, block.headingLevel || 1))) + " " + text : text;
|
|
233
|
+
}
|
|
234
|
+
case "bulletList":
|
|
235
|
+
case "orderedList":
|
|
236
|
+
case "taskList":
|
|
237
|
+
return (block.listItems || []).map((item, index) => {
|
|
238
|
+
const marker = block.kind === "orderedList" ? `${Math.max(1, block.orderedStart || 1) + index}. ` : block.kind === "taskList" ? item.isTaskDone ? "- [x] " : "- [ ] " : "- ";
|
|
239
|
+
return marker + renderBlocks(item.blocks, isMarkdown).split("\n").map((line, lineIndex) => lineIndex && line ? " ".repeat(marker.length) + line : line).join("\n");
|
|
240
|
+
}).join("\n");
|
|
241
|
+
case "quote": {
|
|
242
|
+
const text = renderBlocks(block.children || [], isMarkdown);
|
|
243
|
+
return isMarkdown ? text.split("\n").map((line) => line ? "> " + line : ">").join("\n") : text;
|
|
244
|
+
}
|
|
245
|
+
case "code": {
|
|
246
|
+
if (!isMarkdown) return block.codeText || "";
|
|
247
|
+
let fence = "```";
|
|
248
|
+
while ((block.codeText || "").includes(fence)) fence += "`";
|
|
249
|
+
return `${fence}${block.codeLanguage || ""}
|
|
250
|
+
${block.codeText || ""}
|
|
251
|
+
${fence}`;
|
|
252
|
+
}
|
|
253
|
+
case "rule":
|
|
254
|
+
return "---";
|
|
255
|
+
case "table":
|
|
256
|
+
return (block.tableRows || []).flatMap((row, index) => {
|
|
257
|
+
const cells = row.cells.map((cell) => renderInlines(cell, isMarkdown).replace(/\n/g, " ").replace(isMarkdown ? /\|/g : /$^/, "\\|"));
|
|
258
|
+
if (!isMarkdown) return [cells.join(" | ")];
|
|
259
|
+
const line = `| ${cells.join(" | ")} |`;
|
|
260
|
+
return index === 0 ? [line, `| ${cells.map(() => "---").join(" | ")} |`] : [line];
|
|
261
|
+
}).join("\n");
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function renderInlines(inlines, isMarkdown) {
|
|
265
|
+
return inlines.map((inline) => {
|
|
266
|
+
if (inline.isLineBreak) return "\n";
|
|
267
|
+
const original = inline.text || "";
|
|
268
|
+
if (!isMarkdown || !original.trim()) return original;
|
|
269
|
+
const leading = original.match(/^\s*/u)?.[0] || "";
|
|
270
|
+
const trailing = original.match(/\s*$/u)?.[0] || "";
|
|
271
|
+
const core = original.trim();
|
|
272
|
+
let text = escapeMarkdownText(core);
|
|
273
|
+
if (inline.isCode) {
|
|
274
|
+
let fence = "`";
|
|
275
|
+
while (core.includes(fence)) fence += "`";
|
|
276
|
+
text = fence + core + fence;
|
|
277
|
+
}
|
|
278
|
+
if (inline.isStrikethrough) text = `~~${text}~~`;
|
|
279
|
+
if (inline.isEmphasis) text = `*${text}*`;
|
|
280
|
+
if (inline.isStrong) text = `**${text}**`;
|
|
281
|
+
if (inline.linkHref) text = `[${text}](${inline.linkHref.replace(/\(/g, "%28").replace(/\)/g, "%29").replace(/ /g, "%20")})`;
|
|
282
|
+
return leading + text + trailing;
|
|
283
|
+
}).join("");
|
|
284
|
+
}
|
|
285
|
+
function escapeMarkdownText(value) {
|
|
286
|
+
const characters = [...value];
|
|
287
|
+
return characters.map((character, index) => {
|
|
288
|
+
if ("\\`*[]~".includes(character)) return "\\" + character;
|
|
289
|
+
if (character === "_" && !(isWord(characters[index - 1]) && isWord(characters[index + 1]))) return "\\_";
|
|
290
|
+
return character;
|
|
291
|
+
}).join("");
|
|
292
|
+
}
|
|
293
|
+
function isWord(value) {
|
|
294
|
+
return !!value && /[\p{L}\p{N}]/u.test(value);
|
|
295
|
+
}
|
|
296
|
+
function escapeMarkdownLineStart(line) {
|
|
297
|
+
const match = line.match(/^( *)(.*)$/);
|
|
298
|
+
if (!match) return line;
|
|
299
|
+
const indentation = match[1] || "", trimmed = match[2] || "";
|
|
300
|
+
if (/^[#>\-+=|]/.test(trimmed)) return indentation + "\\" + trimmed;
|
|
301
|
+
return indentation + trimmed.replace(/^([0-9]+)([.)])/, "$1\\$2");
|
|
302
|
+
}
|
|
303
|
+
function appendInline(inlines, span) {
|
|
304
|
+
if (span.isLineBreak) return [...inlines, span];
|
|
305
|
+
if (!span.text) return inlines;
|
|
306
|
+
const previous = inlines.at(-1);
|
|
307
|
+
if (previous && !previous.isLineBreak && !!previous.isStrong === !!span.isStrong && !!previous.isEmphasis === !!span.isEmphasis && !!previous.isCode === !!span.isCode && !!previous.isStrikethrough === !!span.isStrikethrough && (previous.linkHref || "") === (span.linkHref || "")) {
|
|
308
|
+
previous.text = (previous.text || "") + span.text;
|
|
309
|
+
return inlines;
|
|
310
|
+
}
|
|
311
|
+
return [...inlines, span];
|
|
312
|
+
}
|
|
313
|
+
function trimInlineEdges(inlines) {
|
|
314
|
+
const trimmed = [...inlines];
|
|
315
|
+
while (trimmed.length && (trimmed[0].isLineBreak || !(trimmed[0].text || "").trim())) trimmed.shift();
|
|
316
|
+
while (trimmed.length && (trimmed.at(-1).isLineBreak || !(trimmed.at(-1).text || "").trim())) trimmed.pop();
|
|
317
|
+
if (!trimmed.length) return [];
|
|
318
|
+
trimmed[0] = { ...trimmed[0], text: (trimmed[0].text || "").trimStart() };
|
|
319
|
+
trimmed[trimmed.length - 1] = { ...trimmed.at(-1), text: (trimmed.at(-1).text || "").trimEnd() };
|
|
320
|
+
return trimmed;
|
|
321
|
+
}
|
|
322
|
+
function appendParagraphBlock(blocks, inlines) {
|
|
323
|
+
const trimmed = trimInlineEdges(inlines);
|
|
324
|
+
return trimmed.some((inline) => !inline.isLineBreak && (inline.text || "").trim()) ? [...blocks, { kind: "paragraph", inlines: trimmed }] : blocks;
|
|
325
|
+
}
|
|
326
|
+
function flattenBlocksToInlines(blocks) {
|
|
327
|
+
let inlines = [];
|
|
328
|
+
for (const block of blocks) {
|
|
329
|
+
if (inlines.length) inlines = appendInline(inlines, { isLineBreak: true });
|
|
330
|
+
if (block.kind === "paragraph" || block.kind === "heading") for (const inline of block.inlines || []) inlines = appendInline(inlines, inline);
|
|
331
|
+
else inlines = appendInline(inlines, { text: renderBlock(block, false) });
|
|
332
|
+
}
|
|
333
|
+
return inlines;
|
|
334
|
+
}
|
|
335
|
+
function safeLinkHref(value) {
|
|
336
|
+
const href = value.trim();
|
|
337
|
+
if (href.length > 2048 || /[\s<>"]/u.test(href)) return "";
|
|
338
|
+
return /^(https?:\/\/|mailto:)/i.test(href) ? href : "";
|
|
339
|
+
}
|
|
340
|
+
function markdownFenceLanguage(value) {
|
|
341
|
+
const language = value.trim().toLowerCase();
|
|
342
|
+
return language.length <= 32 && /^[a-z0-9+#._-]*$/.test(language) ? language : "";
|
|
343
|
+
}
|
|
344
|
+
function renderStorageDocument(blocks) {
|
|
345
|
+
return blocks.map(renderStorageBlock).join("");
|
|
346
|
+
}
|
|
347
|
+
function renderStorageBlock(block) {
|
|
348
|
+
switch (block.kind) {
|
|
349
|
+
case "paragraph":
|
|
350
|
+
return `<p>${renderStorageInlines(block.inlines || [])}</p>`;
|
|
351
|
+
case "heading": {
|
|
352
|
+
const tag = "h" + Math.min(6, Math.max(1, block.headingLevel || 1));
|
|
353
|
+
return `<${tag}>${renderStorageInlines(block.inlines || [])}</${tag}>`;
|
|
354
|
+
}
|
|
355
|
+
case "bulletList":
|
|
356
|
+
case "orderedList": {
|
|
357
|
+
const tag = block.kind === "orderedList" ? "ol" : "ul";
|
|
358
|
+
const start = tag === "ol" && (block.orderedStart || 0) > 1 ? ` start="${block.orderedStart}"` : "";
|
|
359
|
+
return `<${tag}${start}>${(block.listItems || []).map((item) => `<li>${renderStorageListItem(item.blocks)}</li>`).join("")}</${tag}>`;
|
|
360
|
+
}
|
|
361
|
+
case "taskList":
|
|
362
|
+
return `<ac:task-list>${(block.listItems || []).map((item) => `<ac:task><ac:task-status>${item.isTaskDone ? "complete" : "incomplete"}</ac:task-status><ac:task-body>${renderStorageListItem(item.blocks)}</ac:task-body></ac:task>`).join("")}</ac:task-list>`;
|
|
363
|
+
case "quote":
|
|
364
|
+
return `<blockquote>${renderStorageDocument(block.children || [])}</blockquote>`;
|
|
365
|
+
case "code":
|
|
366
|
+
return `<pre>${escapeStorageText(block.codeText || "")}</pre>`;
|
|
367
|
+
case "rule":
|
|
368
|
+
return "<hr />";
|
|
369
|
+
case "table":
|
|
370
|
+
return `<table><tbody>${(block.tableRows || []).map((row) => `<tr>${row.cells.map((cell) => `<${row.isHeader ? "th" : "td"}>${renderStorageInlines(cell)}</${row.isHeader ? "th" : "td"}>`).join("")}</tr>`).join("")}</tbody></table>`;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
function renderStorageListItem(blocks) {
|
|
374
|
+
return blocks.length && blocks[0].kind === "paragraph" ? renderStorageInlines(blocks[0].inlines || []) + renderStorageDocument(blocks.slice(1)) : renderStorageDocument(blocks);
|
|
375
|
+
}
|
|
376
|
+
function renderStorageInlines(inlines) {
|
|
377
|
+
return inlines.map((inline) => {
|
|
378
|
+
if (inline.isLineBreak) return "<br />";
|
|
379
|
+
let opening = "", closing = "";
|
|
380
|
+
if (inline.linkHref) {
|
|
381
|
+
opening += `<a href="${escapeStorageAttribute(inline.linkHref)}">`;
|
|
382
|
+
closing = "</a>" + closing;
|
|
383
|
+
}
|
|
384
|
+
for (const [isSet, open, close] of [
|
|
385
|
+
[inline.isStrong, "<strong>", "</strong>"],
|
|
386
|
+
[inline.isEmphasis, "<em>", "</em>"],
|
|
387
|
+
[inline.isStrikethrough, '<span style="text-decoration: line-through;">', "</span>"],
|
|
388
|
+
[inline.isCode, "<code>", "</code>"]
|
|
389
|
+
]) if (isSet) {
|
|
390
|
+
opening += open;
|
|
391
|
+
closing = close + closing;
|
|
392
|
+
}
|
|
393
|
+
return opening + escapeStorageText(inline.text || "") + closing;
|
|
394
|
+
}).join("");
|
|
395
|
+
}
|
|
396
|
+
function escapeStorageText(value) {
|
|
397
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
398
|
+
}
|
|
399
|
+
function escapeStorageAttribute(value) {
|
|
400
|
+
return escapeStorageText(value).replace(/"/g, """).replace(/'/g, "'");
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// src/markdown.ts
|
|
404
|
+
var headingPattern = /^ {0,3}(#{1,6})(?:[ \t]+(.*?))?(?:[ \t]+#+)?[ \t]*$/;
|
|
405
|
+
var thematicBreakPattern = /^ {0,3}(?:(?:\*[ \t]*){3,}|(?:-[ \t]*){3,}|(?:_[ \t]*){3,})$/;
|
|
406
|
+
var fenceOpeningPattern = /^( {0,3})(`{3,}|~{3,})[ \t]*([^`]*?)[ \t]*$/;
|
|
407
|
+
var listMarkerPattern = /^( {0,3})([-*+]|[0-9]{1,9}[.)])([ \t]+|$)/;
|
|
408
|
+
var tableSeparatorPattern = /^ {0,3}\|?[ \t]*:?-+:?[ \t]*(\|[ \t]*:?-+:?[ \t]*)*\|?[ \t]*$/;
|
|
409
|
+
var taskMarkerPattern = /^\[([ xX])\][ \t]+/;
|
|
410
|
+
function convertWrittenBody(body, format, fieldName) {
|
|
411
|
+
if (!body.trim()) throw new TypeError(`${fieldName} is required`);
|
|
412
|
+
if ([...body].length > 262144) throw new TypeError(`${fieldName} cannot exceed 262144 characters`);
|
|
413
|
+
if ([...body].some((character) => {
|
|
414
|
+
const code = character.codePointAt(0);
|
|
415
|
+
return code === 127 || code < 32 && code !== 9 && code !== 10 && code !== 13;
|
|
416
|
+
})) throw new TypeError(`${fieldName} cannot contain control characters`);
|
|
417
|
+
const normalized = body.replace(/\r\n?/g, "\n");
|
|
418
|
+
const blocks = !format || format === "markdown" ? readMarkdownBlocks(normalized.replace(/^\n+|\n+$/g, "").split("\n"), 0) : format === "plainText" ? readPlainText(normalized) : void 0;
|
|
419
|
+
if (!blocks) throw new TypeError(`${fieldName}Format must be markdown or plainText`);
|
|
420
|
+
return { storage: renderStorageDocument(blocks), comparisonText: documentComparisonText(blocks) };
|
|
421
|
+
}
|
|
422
|
+
function readPlainText(text) {
|
|
423
|
+
return text.replace(/^\n+|\n+$/g, "").split(/\n[ \t]*\n+/).reduce((blocks, paragraph) => {
|
|
424
|
+
let inlines = [];
|
|
425
|
+
for (const [index, line] of paragraph.split("\n").entries()) {
|
|
426
|
+
if (index) inlines = appendInline(inlines, { isLineBreak: true });
|
|
427
|
+
inlines = appendInline(inlines, { text: line });
|
|
428
|
+
}
|
|
429
|
+
return appendParagraphBlock(blocks, inlines);
|
|
430
|
+
}, []);
|
|
431
|
+
}
|
|
432
|
+
function readMarkdownBlocks(lines, depth) {
|
|
433
|
+
const blocks = [];
|
|
434
|
+
for (let index = 0; index < lines.length; ) {
|
|
435
|
+
const line = lines[index];
|
|
436
|
+
if (depth > 64) {
|
|
437
|
+
blocks.push({ kind: "paragraph", inlines: [{ text: lines.slice(index).join(" ") }] });
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
440
|
+
if (!line.trim()) {
|
|
441
|
+
index++;
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
const fence = line.match(fenceOpeningPattern);
|
|
445
|
+
if (fence) {
|
|
446
|
+
const marker = fence[2], indentation = fence[1].length;
|
|
447
|
+
const language = markdownFenceLanguage((fence[3] || "").trim().split(" ")[0] || "");
|
|
448
|
+
const code = [];
|
|
449
|
+
index++;
|
|
450
|
+
while (index < lines.length) {
|
|
451
|
+
const candidate = lines[index].trim();
|
|
452
|
+
if (candidate.startsWith(marker[0]) && [...candidate].every((character) => character === marker[0]) && candidate.length >= marker.length) {
|
|
453
|
+
index++;
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
code.push(removeIndentation(lines[index], indentation));
|
|
457
|
+
index++;
|
|
458
|
+
}
|
|
459
|
+
blocks.push({ kind: "code", codeText: code.join("\n"), codeLanguage: language });
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
const heading = line.match(headingPattern);
|
|
463
|
+
if (heading) {
|
|
464
|
+
blocks.push({ kind: "heading", headingLevel: heading[1].length, inlines: readMarkdownInlines(heading[2] || "", {}, 0) });
|
|
465
|
+
index++;
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
if (thematicBreakPattern.test(line)) {
|
|
469
|
+
blocks.push({ kind: "rule" });
|
|
470
|
+
index++;
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
if (isBlockQuoteLine(line)) {
|
|
474
|
+
const quoted = [];
|
|
475
|
+
while (index < lines.length && isBlockQuoteLine(lines[index])) quoted.push(lines[index++].trimStart().replace(/^> ?/, ""));
|
|
476
|
+
blocks.push({ kind: "quote", children: readMarkdownBlocks(quoted, depth + 1) });
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
if (listMarkerPattern.test(line)) {
|
|
480
|
+
const [block, next] = readList(lines, index, depth);
|
|
481
|
+
blocks.push(block);
|
|
482
|
+
index = next;
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
if (index + 1 < lines.length && line.includes("|") && lines[index + 1].includes("|") && tableSeparatorPattern.test(lines[index + 1])) {
|
|
486
|
+
const rows = [{ isHeader: true, cells: readTableCells(line) }];
|
|
487
|
+
index += 2;
|
|
488
|
+
while (index < lines.length && lines[index].includes("|") && lines[index].trim()) rows.push({ isHeader: false, cells: readTableCells(lines[index++]) });
|
|
489
|
+
blocks.push({ kind: "table", tableRows: rows });
|
|
490
|
+
continue;
|
|
491
|
+
}
|
|
492
|
+
const paragraphLines = [];
|
|
493
|
+
while (index < lines.length && lines[index].trim() && (!paragraphLines.length || !startsMarkdownBlock(lines[index]))) paragraphLines.push(lines[index++].trim());
|
|
494
|
+
const paragraph = appendParagraphBlock([], readMarkdownInlines(paragraphLines.join("\n"), {}, 0));
|
|
495
|
+
blocks.push(...paragraph);
|
|
496
|
+
}
|
|
497
|
+
return blocks;
|
|
498
|
+
}
|
|
499
|
+
function readList(lines, start, depth) {
|
|
500
|
+
const first = lines[start].match(listMarkerPattern);
|
|
501
|
+
const isOrdered = /^[0-9]/.test(first[2]);
|
|
502
|
+
const block = { kind: isOrdered ? "orderedList" : "bulletList", orderedStart: isOrdered ? Number.parseInt(first[2], 10) : 0, listItems: [] };
|
|
503
|
+
let index = start;
|
|
504
|
+
const groups = [];
|
|
505
|
+
while (index < lines.length) {
|
|
506
|
+
const marker = lines[index].match(listMarkerPattern);
|
|
507
|
+
if (!marker || /^[0-9]/.test(marker[2]) !== isOrdered || !isOrdered && marker[2] !== first[2]) break;
|
|
508
|
+
let indentation = marker[0].length;
|
|
509
|
+
if (!marker[3].trim() && marker[3].length > 4) indentation = marker[1].length + marker[2].length + 1;
|
|
510
|
+
const itemLines = [lines[index].slice(marker[0].length)];
|
|
511
|
+
index++;
|
|
512
|
+
while (index < lines.length) {
|
|
513
|
+
const next = lines[index];
|
|
514
|
+
if (!next.trim()) {
|
|
515
|
+
if (index + 1 < lines.length && leadingSpaces(lines[index + 1]) >= indentation) {
|
|
516
|
+
itemLines.push("");
|
|
517
|
+
index++;
|
|
518
|
+
continue;
|
|
519
|
+
}
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
if (leadingSpaces(next) < indentation) break;
|
|
523
|
+
itemLines.push(removeIndentation(next, indentation));
|
|
524
|
+
index++;
|
|
525
|
+
}
|
|
526
|
+
groups.push(itemLines);
|
|
527
|
+
while (index < lines.length && !lines[index].trim() && index + 1 < lines.length && listMarkerPattern.test(lines[index + 1])) index++;
|
|
528
|
+
}
|
|
529
|
+
const isTask = !isOrdered && groups.every((group) => taskMarkerPattern.test(group[0]));
|
|
530
|
+
block.listItems = groups.map((group) => {
|
|
531
|
+
let isTaskDone = false;
|
|
532
|
+
if (isTask) {
|
|
533
|
+
const match = group[0].match(taskMarkerPattern);
|
|
534
|
+
isTaskDone = match[1] !== " ";
|
|
535
|
+
group[0] = group[0].slice(match[0].length);
|
|
536
|
+
}
|
|
537
|
+
return { blocks: readMarkdownBlocks(group, depth + 1), isTaskDone };
|
|
538
|
+
});
|
|
539
|
+
if (isTask) block.kind = "taskList";
|
|
540
|
+
return [block, index];
|
|
541
|
+
}
|
|
542
|
+
function readTableCells(line) {
|
|
543
|
+
let value = line.trim().replace(/^\|/, "");
|
|
544
|
+
if (value.endsWith("|") && !value.endsWith("\\|")) value = value.slice(0, -1);
|
|
545
|
+
const cells = [];
|
|
546
|
+
let cell = "", escaped = false;
|
|
547
|
+
for (const character of value) {
|
|
548
|
+
if (escaped) {
|
|
549
|
+
cell += (character === "|" ? "" : "\\") + character;
|
|
550
|
+
escaped = false;
|
|
551
|
+
} else if (character === "\\") escaped = true;
|
|
552
|
+
else if (character === "|") {
|
|
553
|
+
cells.push(readMarkdownInlines(cell.trim(), {}, 0));
|
|
554
|
+
cell = "";
|
|
555
|
+
} else cell += character;
|
|
556
|
+
}
|
|
557
|
+
cells.push(readMarkdownInlines(cell.trim(), {}, 0));
|
|
558
|
+
return cells;
|
|
559
|
+
}
|
|
560
|
+
function readMarkdownInlines(value, style, depth) {
|
|
561
|
+
const characters = [...value];
|
|
562
|
+
let inlines = [], pending = "";
|
|
563
|
+
const flush = () => {
|
|
564
|
+
inlines = appendInline(inlines, { ...style, text: pending });
|
|
565
|
+
pending = "";
|
|
566
|
+
};
|
|
567
|
+
for (let index = 0; index < characters.length; ) {
|
|
568
|
+
const character = characters[index];
|
|
569
|
+
if (depth >= 32) {
|
|
570
|
+
pending += character;
|
|
571
|
+
index++;
|
|
572
|
+
continue;
|
|
573
|
+
}
|
|
574
|
+
if (character === "\\" && index + 1 < characters.length && isMarkdownPunctuation(characters[index + 1])) {
|
|
575
|
+
pending += characters[index + 1];
|
|
576
|
+
index += 2;
|
|
577
|
+
continue;
|
|
578
|
+
}
|
|
579
|
+
if (character === "\n") {
|
|
580
|
+
flush();
|
|
581
|
+
inlines = appendInline(inlines, { isLineBreak: true });
|
|
582
|
+
index++;
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
if (character === "`") {
|
|
586
|
+
const code = readCodeSpan(characters, index);
|
|
587
|
+
if (code) {
|
|
588
|
+
flush();
|
|
589
|
+
inlines = appendInline(inlines, { ...style, text: code.text, isCode: true });
|
|
590
|
+
index = code.end;
|
|
591
|
+
continue;
|
|
592
|
+
}
|
|
593
|
+
const length = delimiterRunLength(characters, index, character);
|
|
594
|
+
pending += character.repeat(length);
|
|
595
|
+
index += length;
|
|
596
|
+
continue;
|
|
597
|
+
}
|
|
598
|
+
if (character === "[") {
|
|
599
|
+
const link = readMarkdownLink(characters, index);
|
|
600
|
+
if (link) {
|
|
601
|
+
flush();
|
|
602
|
+
for (const span of readMarkdownInlines(link.label, { ...style, linkHref: safeLinkHref(link.href) }, depth + 1)) inlines = appendInline(inlines, span);
|
|
603
|
+
index = link.end;
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
if (character === "<") {
|
|
608
|
+
const end = characters.indexOf(">", index + 1);
|
|
609
|
+
if (end >= 0) {
|
|
610
|
+
const href = characters.slice(index + 1, end).join("");
|
|
611
|
+
if (href && safeLinkHref(href) === href) {
|
|
612
|
+
flush();
|
|
613
|
+
inlines = appendInline(inlines, { ...style, text: href, linkHref: href });
|
|
614
|
+
index = end + 1;
|
|
615
|
+
continue;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
if ("*_~".includes(character)) {
|
|
620
|
+
const emphasis = readEmphasis(characters, index, style);
|
|
621
|
+
if (emphasis) {
|
|
622
|
+
flush();
|
|
623
|
+
for (const span of readMarkdownInlines(emphasis.inner, emphasis.style, depth + 1)) inlines = appendInline(inlines, span);
|
|
624
|
+
index = emphasis.end;
|
|
625
|
+
continue;
|
|
626
|
+
}
|
|
627
|
+
const length = delimiterRunLength(characters, index, character);
|
|
628
|
+
pending += character.repeat(length);
|
|
629
|
+
index += length;
|
|
630
|
+
continue;
|
|
631
|
+
}
|
|
632
|
+
pending += character;
|
|
633
|
+
index++;
|
|
634
|
+
}
|
|
635
|
+
flush();
|
|
636
|
+
return trimInlineEdges(inlines);
|
|
637
|
+
}
|
|
638
|
+
function readCodeSpan(characters, start) {
|
|
639
|
+
const length = delimiterRunLength(characters, start, "`");
|
|
640
|
+
for (let index = start + length; index < characters.length; ) {
|
|
641
|
+
if (characters[index] !== "`") {
|
|
642
|
+
index++;
|
|
643
|
+
continue;
|
|
644
|
+
}
|
|
645
|
+
const closing = delimiterRunLength(characters, index, "`");
|
|
646
|
+
if (closing === length) {
|
|
647
|
+
let text = characters.slice(start + length, index).join("");
|
|
648
|
+
if (text.length >= 2 && text.startsWith(" ") && text.endsWith(" ") && text.trim()) text = text.slice(1, -1);
|
|
649
|
+
return { text: text.replace(/\n/g, " "), end: index + closing };
|
|
650
|
+
}
|
|
651
|
+
index += closing;
|
|
652
|
+
}
|
|
653
|
+
return void 0;
|
|
654
|
+
}
|
|
655
|
+
function readMarkdownLink(characters, start) {
|
|
656
|
+
let depth = 0;
|
|
657
|
+
for (let index = start; index < characters.length; index++) {
|
|
658
|
+
if (characters[index] === "\\") {
|
|
659
|
+
index++;
|
|
660
|
+
continue;
|
|
661
|
+
}
|
|
662
|
+
if (characters[index] === "[") depth++;
|
|
663
|
+
if (characters[index] !== "]") continue;
|
|
664
|
+
depth--;
|
|
665
|
+
if (depth > 0) continue;
|
|
666
|
+
if (characters[index + 1] !== "(") return void 0;
|
|
667
|
+
const closing = balancedClosing(characters, index + 2);
|
|
668
|
+
if (closing < 0) return void 0;
|
|
669
|
+
const href = characters.slice(index + 2, closing).join("").trim().replace(/^</, "").replace(/>$/, "");
|
|
670
|
+
if (!href || /[ \t\n]/.test(href)) return void 0;
|
|
671
|
+
return { label: characters.slice(start + 1, index).join(""), href, end: closing + 1 };
|
|
672
|
+
}
|
|
673
|
+
return void 0;
|
|
674
|
+
}
|
|
675
|
+
function balancedClosing(characters, start) {
|
|
676
|
+
let depth = 0;
|
|
677
|
+
for (let index = start; index < characters.length; index++) {
|
|
678
|
+
const character = characters[index];
|
|
679
|
+
if (character === "\\") {
|
|
680
|
+
index++;
|
|
681
|
+
continue;
|
|
682
|
+
}
|
|
683
|
+
if (character === "(") depth++;
|
|
684
|
+
if (character === ")") {
|
|
685
|
+
if (!depth) return index;
|
|
686
|
+
depth--;
|
|
687
|
+
}
|
|
688
|
+
if (character === "\n") return -1;
|
|
689
|
+
}
|
|
690
|
+
return -1;
|
|
691
|
+
}
|
|
692
|
+
function readEmphasis(characters, start, style) {
|
|
693
|
+
const character = characters[start], runLength = delimiterRunLength(characters, start, character);
|
|
694
|
+
if (character === "~" && runLength < 2) return void 0;
|
|
695
|
+
const length = Math.min(runLength, 2), contentStart = start + length;
|
|
696
|
+
if (contentStart >= characters.length || /\s/u.test(characters[contentStart])) return void 0;
|
|
697
|
+
if (character === "_" && start > 0 && isWord2(characters[start - 1])) return void 0;
|
|
698
|
+
for (let index = contentStart + 1; index < characters.length; index++) {
|
|
699
|
+
if (characters[index] === "\\") {
|
|
700
|
+
index++;
|
|
701
|
+
continue;
|
|
702
|
+
}
|
|
703
|
+
if (characters[index] !== character) continue;
|
|
704
|
+
const closingRun = delimiterRunLength(characters, index, character);
|
|
705
|
+
if (closingRun < length || /\s/u.test(characters[index - 1])) {
|
|
706
|
+
index += closingRun - 1;
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
const closing = index + closingRun - length, end = closing + length;
|
|
710
|
+
if (character === "_" && end < characters.length && isWord2(characters[end])) {
|
|
711
|
+
index += closingRun - 1;
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
const nextStyle = { ...style, ...character === "~" ? { isStrikethrough: true } : length === 2 ? { isStrong: true } : { isEmphasis: true } };
|
|
715
|
+
return { inner: characters.slice(contentStart, closing).join(""), style: nextStyle, end };
|
|
716
|
+
}
|
|
717
|
+
return void 0;
|
|
718
|
+
}
|
|
719
|
+
function isWord2(character) {
|
|
720
|
+
return /[\p{L}\p{N}]/u.test(character);
|
|
721
|
+
}
|
|
722
|
+
function isMarkdownPunctuation(character) {
|
|
723
|
+
return /^[!-/:-@[-`{-~]$/.test(character) || "`$^+<=>|~".includes(character);
|
|
724
|
+
}
|
|
725
|
+
function delimiterRunLength(characters, start, character) {
|
|
726
|
+
let length = 0;
|
|
727
|
+
while (characters[start + length] === character) length++;
|
|
728
|
+
return length;
|
|
729
|
+
}
|
|
730
|
+
function isBlockQuoteLine(line) {
|
|
731
|
+
return line.trimStart().startsWith(">") && leadingSpaces(line) <= 3;
|
|
732
|
+
}
|
|
733
|
+
function startsMarkdownBlock(line) {
|
|
734
|
+
return fenceOpeningPattern.test(line) || headingPattern.test(line) || thematicBreakPattern.test(line) || isBlockQuoteLine(line) || listMarkerPattern.test(line);
|
|
735
|
+
}
|
|
736
|
+
function leadingSpaces(line) {
|
|
737
|
+
return line.match(/^ */)?.[0].length || 0;
|
|
738
|
+
}
|
|
739
|
+
function removeIndentation(line, amount) {
|
|
740
|
+
return line.slice(Math.min(leadingSpaces(line), amount));
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
// src/storage.ts
|
|
744
|
+
import { parseDocument } from "htmlparser2";
|
|
745
|
+
var blockElements = /* @__PURE__ */ new Set(["p", "h1", "h2", "h3", "h4", "h5", "h6", "ul", "ol", "ac:task-list", "blockquote", "pre", "hr", "table", "div", "section", "ac:layout", "ac:layout-section", "ac:layout-cell", "ac:rich-text-body", "ac:adf-extension"]);
|
|
746
|
+
function parseStorageDocument(storage) {
|
|
747
|
+
if (Buffer.byteLength(storage) > 16e6) throw new TypeError("body is not readable Confluence storage format");
|
|
748
|
+
if (storage.includes("<![CDATA[") && !/<!\[CDATA\[[\s\S]*?\]\]>/.test(storage)) throw new TypeError("body is not readable Confluence storage format");
|
|
749
|
+
const html = storage.replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, (_match, contents) => contents.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"));
|
|
750
|
+
const parsed = parseDocument(`<storage-root>${html}</storage-root>`, { decodeEntities: true, recognizeSelfClosing: true, lowerCaseTags: true });
|
|
751
|
+
const root = (parsed.children || []).find((node) => node.name === "storage-root");
|
|
752
|
+
if (!root) throw new TypeError("body is not readable Confluence storage format");
|
|
753
|
+
let count = 0;
|
|
754
|
+
const pending = [root];
|
|
755
|
+
while (pending.length) {
|
|
756
|
+
const node = pending.pop();
|
|
757
|
+
if (++count > 2e5) throw new TypeError("body is not readable Confluence storage format");
|
|
758
|
+
pending.push(...node.children || []);
|
|
759
|
+
}
|
|
760
|
+
return readBlocks(root.children || [], 0);
|
|
761
|
+
}
|
|
762
|
+
function readBlocks(nodes, depth) {
|
|
763
|
+
let blocks = [], inlines = [];
|
|
764
|
+
for (const node of nodes) {
|
|
765
|
+
if (isBlockElement(node)) {
|
|
766
|
+
blocks = appendParagraphBlock(blocks, inlines);
|
|
767
|
+
inlines = [];
|
|
768
|
+
blocks.push(...readBlock(node, depth + 1));
|
|
769
|
+
} else inlines = appendInlines(inlines, node, {}, depth + 1);
|
|
770
|
+
}
|
|
771
|
+
return appendParagraphBlock(blocks, inlines);
|
|
772
|
+
}
|
|
773
|
+
function readBlock(node, depth) {
|
|
774
|
+
if (depth > 64) return [];
|
|
775
|
+
const children = node.children || [];
|
|
776
|
+
switch (node.name) {
|
|
777
|
+
case "p":
|
|
778
|
+
return appendParagraphBlock([], readInlines(children, {}, depth));
|
|
779
|
+
case "h1":
|
|
780
|
+
case "h2":
|
|
781
|
+
case "h3":
|
|
782
|
+
case "h4":
|
|
783
|
+
case "h5":
|
|
784
|
+
case "h6":
|
|
785
|
+
return [{ kind: "heading", headingLevel: Number(node.name[1]), inlines: trimInlineEdges(readInlines(children, {}, depth)) }];
|
|
786
|
+
case "ul":
|
|
787
|
+
case "ol": {
|
|
788
|
+
const isOrdered = node.name === "ol";
|
|
789
|
+
return [{ kind: isOrdered ? "orderedList" : "bulletList", orderedStart: Number(node.attribs?.start || 0), listItems: children.filter((child) => child.name === "li").map((child) => ({ blocks: readBlocks(child.children || [], depth) })) }];
|
|
790
|
+
}
|
|
791
|
+
case "ac:task-list":
|
|
792
|
+
return [{ kind: "taskList", listItems: children.filter((child) => child.name === "ac:task").map((task) => ({
|
|
793
|
+
isTaskDone: (task.children || []).some((part) => part.name === "ac:task-status" && storageText(part).trim() === "complete"),
|
|
794
|
+
blocks: readBlocks((task.children || []).find((part) => part.name === "ac:task-body")?.children || [], depth)
|
|
795
|
+
})) }];
|
|
796
|
+
case "blockquote":
|
|
797
|
+
return [{ kind: "quote", children: readBlocks(children, depth) }];
|
|
798
|
+
case "pre":
|
|
799
|
+
return [{ kind: "code", codeText: storageText(node).replace(/^\n+|\n+$/g, "") }];
|
|
800
|
+
case "hr":
|
|
801
|
+
return [{ kind: "rule" }];
|
|
802
|
+
case "table":
|
|
803
|
+
return [{ kind: "table", tableRows: readTableRows(node, depth) }];
|
|
804
|
+
case "ac:structured-macro":
|
|
805
|
+
case "ac:macro":
|
|
806
|
+
return readMacro(node, depth);
|
|
807
|
+
case "ac:adf-extension":
|
|
808
|
+
return readBlocks(children.find((child) => child.name === "ac:adf-fallback")?.children || [], depth);
|
|
809
|
+
default:
|
|
810
|
+
return readBlocks(children, depth);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
function readTableRows(node, depth) {
|
|
814
|
+
const rows = (node.children || []).flatMap((child) => child.name === "tr" ? [child] : ["thead", "tbody", "tfoot"].includes(child.name || "") ? (child.children || []).filter((row) => row.name === "tr") : []);
|
|
815
|
+
return rows.map((row) => {
|
|
816
|
+
const cells = (row.children || []).filter((child) => child.name === "th" || child.name === "td");
|
|
817
|
+
return { isHeader: !!cells.length && cells.every((cell) => cell.name === "th"), cells: cells.map((cell) => flattenBlocksToInlines(readBlocks(cell.children || [], depth))) };
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
function readMacro(node, depth) {
|
|
821
|
+
const name = node.attribs?.["ac:name"] || "";
|
|
822
|
+
const children = node.children || [];
|
|
823
|
+
const parameters = new Map(children.filter((child) => child.name === "ac:parameter").map((child) => [child.attribs?.["ac:name"] || "", storageText(child).trim()]));
|
|
824
|
+
const rich = children.find((child) => child.name === "ac:rich-text-body");
|
|
825
|
+
const plain = children.find((child) => child.name === "ac:plain-text-body");
|
|
826
|
+
if (name === "code" || name === "noformat") return [{ kind: "code", codeLanguage: markdownFenceLanguage(parameters.get("language") || ""), codeText: storageText(plain).replace(/^\n+|\n+$/g, "") }];
|
|
827
|
+
if (rich && ["info", "note", "warning", "tip", "panel"].includes(name)) return [{ kind: "quote", children: readBlocks(rich.children || [], depth) }];
|
|
828
|
+
if (rich) return readBlocks(rich.children || [], depth);
|
|
829
|
+
if (plain) return [{ kind: "paragraph", inlines: [{ text: storageText(plain).trim() }] }];
|
|
830
|
+
return [];
|
|
831
|
+
}
|
|
832
|
+
function readInlines(nodes, style, depth) {
|
|
833
|
+
let inlines = [];
|
|
834
|
+
for (const node of nodes) inlines = appendInlines(inlines, node, style, depth + 1);
|
|
835
|
+
return inlines;
|
|
836
|
+
}
|
|
837
|
+
function appendInlines(inlines, node, style, depth) {
|
|
838
|
+
if (depth > 64) return inlines;
|
|
839
|
+
if (node.type === "text") return appendInline(inlines, { ...style, text: collapseWhitespace(node.data || "") });
|
|
840
|
+
let nextStyle = style;
|
|
841
|
+
switch (node.name) {
|
|
842
|
+
case "br":
|
|
843
|
+
return appendInline(inlines, { isLineBreak: true });
|
|
844
|
+
case "strong":
|
|
845
|
+
case "b":
|
|
846
|
+
nextStyle = { ...style, isStrong: true };
|
|
847
|
+
break;
|
|
848
|
+
case "em":
|
|
849
|
+
case "i":
|
|
850
|
+
nextStyle = { ...style, isEmphasis: true };
|
|
851
|
+
break;
|
|
852
|
+
case "code":
|
|
853
|
+
case "tt":
|
|
854
|
+
nextStyle = { ...style, isCode: true };
|
|
855
|
+
break;
|
|
856
|
+
case "s":
|
|
857
|
+
case "del":
|
|
858
|
+
case "strike":
|
|
859
|
+
nextStyle = { ...style, isStrikethrough: true };
|
|
860
|
+
break;
|
|
861
|
+
case "span":
|
|
862
|
+
if ((node.attribs?.style || "").toLowerCase().includes("line-through")) nextStyle = { ...style, isStrikethrough: true };
|
|
863
|
+
break;
|
|
864
|
+
case "a":
|
|
865
|
+
nextStyle = { ...style, linkHref: safeLinkHref(node.attribs?.href || "") };
|
|
866
|
+
break;
|
|
867
|
+
case "ac:link":
|
|
868
|
+
return appendLinkInlines(inlines, node, style, depth);
|
|
869
|
+
case "ac:emoticon":
|
|
870
|
+
return appendInline(inlines, { ...style, text: node.attribs?.["ac:emoji-fallback"] || "" });
|
|
871
|
+
case "time":
|
|
872
|
+
return appendInline(inlines, { ...style, text: node.attribs?.datetime || "" });
|
|
873
|
+
case "ac:structured-macro":
|
|
874
|
+
return appendInlineMacro(inlines, node, style);
|
|
875
|
+
case "ac:image":
|
|
876
|
+
case "ac:placeholder":
|
|
877
|
+
case "ac:parameter":
|
|
878
|
+
case "ac:adf-attribute":
|
|
879
|
+
case "ri:user":
|
|
880
|
+
case "ri:attachment":
|
|
881
|
+
case "ri:page":
|
|
882
|
+
return inlines;
|
|
883
|
+
case "p":
|
|
884
|
+
case "div":
|
|
885
|
+
case "li":
|
|
886
|
+
case "h1":
|
|
887
|
+
case "h2":
|
|
888
|
+
case "h3":
|
|
889
|
+
case "h4":
|
|
890
|
+
case "h5":
|
|
891
|
+
case "h6":
|
|
892
|
+
case "tr":
|
|
893
|
+
case "blockquote":
|
|
894
|
+
case "pre":
|
|
895
|
+
if (inlines.length) inlines = appendInline(inlines, { isLineBreak: true });
|
|
896
|
+
break;
|
|
897
|
+
}
|
|
898
|
+
for (const child of node.children || []) inlines = appendInlines(inlines, child, nextStyle, depth + 1);
|
|
899
|
+
return inlines;
|
|
900
|
+
}
|
|
901
|
+
function appendLinkInlines(inlines, node, style, depth) {
|
|
902
|
+
let fallback = "", body, nextStyle = style;
|
|
903
|
+
for (const child of node.children || []) {
|
|
904
|
+
switch (child.name) {
|
|
905
|
+
case "ac:link-body":
|
|
906
|
+
body = child;
|
|
907
|
+
break;
|
|
908
|
+
case "ac:plain-text-link-body":
|
|
909
|
+
fallback = storageText(child).trim();
|
|
910
|
+
break;
|
|
911
|
+
case "ri:page":
|
|
912
|
+
if (!fallback) fallback = child.attribs?.["ri:content-title"] || "";
|
|
913
|
+
break;
|
|
914
|
+
case "ri:attachment":
|
|
915
|
+
if (!fallback) fallback = child.attribs?.["ri:filename"] || "";
|
|
916
|
+
break;
|
|
917
|
+
case "ri:url":
|
|
918
|
+
nextStyle = { ...style, linkHref: safeLinkHref(child.attribs?.["ri:value"] || "") };
|
|
919
|
+
if (!fallback) fallback = child.attribs?.["ri:value"] || "";
|
|
920
|
+
break;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
if (body) for (const child of body.children || []) inlines = appendInlines(inlines, child, nextStyle, depth + 1);
|
|
924
|
+
else inlines = appendInline(inlines, { ...nextStyle, text: fallback });
|
|
925
|
+
return inlines;
|
|
926
|
+
}
|
|
927
|
+
function appendInlineMacro(inlines, node, style) {
|
|
928
|
+
if (node.attribs?.["ac:name"] !== "status") return inlines;
|
|
929
|
+
const title = (node.children || []).find((child) => child.name === "ac:parameter" && child.attribs?.["ac:name"] === "title");
|
|
930
|
+
return title ? appendInline(inlines, { ...style, text: storageText(title).trim() }) : inlines;
|
|
931
|
+
}
|
|
932
|
+
function isBlockElement(node) {
|
|
933
|
+
return blockElements.has(node.name || "") || ["ac:structured-macro", "ac:macro"].includes(node.name || "") && node.attribs?.["ac:name"] !== "status";
|
|
934
|
+
}
|
|
935
|
+
function storageText(node, depth = 0) {
|
|
936
|
+
if (!node || depth > 64) return "";
|
|
937
|
+
return node.type === "text" ? node.data || "" : (node.children || []).map((child) => storageText(child, depth + 1)).join("");
|
|
938
|
+
}
|
|
939
|
+
function collapseWhitespace(value) {
|
|
940
|
+
return value.replace(/[ \t\n\r\u00a0]+/g, " ");
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
// src/adf.ts
|
|
944
|
+
function parseADFDocument(value) {
|
|
945
|
+
if (!value.trim()) return [];
|
|
946
|
+
let document;
|
|
947
|
+
try {
|
|
948
|
+
document = JSON.parse(value);
|
|
949
|
+
} catch {
|
|
950
|
+
throw new TypeError("body is not readable Atlassian Document Format");
|
|
951
|
+
}
|
|
952
|
+
if (!isADFNode(document) || document.type !== "doc") throw new TypeError("body is not readable Atlassian Document Format");
|
|
953
|
+
return readBlocks2(document.content || [], 0);
|
|
954
|
+
}
|
|
955
|
+
function isADFNode(value) {
|
|
956
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
957
|
+
}
|
|
958
|
+
function readBlocks2(nodes, depth) {
|
|
959
|
+
let blocks = [], inlines = [];
|
|
960
|
+
for (const node of nodes) {
|
|
961
|
+
if (["text", "hardBreak", "mention", "status", "emoji", "inlineCard", "date", "placeholder", "inlineExtension", "mediaInline"].includes(node.type || "")) {
|
|
962
|
+
inlines = appendADFInline(inlines, node);
|
|
963
|
+
continue;
|
|
964
|
+
}
|
|
965
|
+
blocks = appendParagraphBlock(blocks, inlines);
|
|
966
|
+
inlines = [];
|
|
967
|
+
blocks.push(...readBlock2(node, depth + 1));
|
|
968
|
+
}
|
|
969
|
+
return appendParagraphBlock(blocks, inlines);
|
|
970
|
+
}
|
|
971
|
+
function readBlock2(node, depth) {
|
|
972
|
+
if (depth > 64) return [];
|
|
973
|
+
const content = Array.isArray(node.content) ? node.content : [];
|
|
974
|
+
switch (node.type) {
|
|
975
|
+
case "paragraph":
|
|
976
|
+
return appendParagraphBlock([], readInlines2(content));
|
|
977
|
+
case "heading":
|
|
978
|
+
return [{ kind: "heading", headingLevel: numberAttribute(node.attrs, "level"), inlines: trimInlineEdges(readInlines2(content)) }];
|
|
979
|
+
case "bulletList":
|
|
980
|
+
case "orderedList":
|
|
981
|
+
case "taskList":
|
|
982
|
+
case "decisionList":
|
|
983
|
+
return [readList2(node, depth)];
|
|
984
|
+
case "blockquote":
|
|
985
|
+
case "panel":
|
|
986
|
+
return [{ kind: "quote", children: readBlocks2(content, depth) }];
|
|
987
|
+
case "codeBlock":
|
|
988
|
+
return [{ kind: "code", codeLanguage: markdownFenceLanguage(stringAttribute(node.attrs, "language")), codeText: content.map((child) => child.text || "").join("") }];
|
|
989
|
+
case "rule":
|
|
990
|
+
return [{ kind: "rule" }];
|
|
991
|
+
case "table":
|
|
992
|
+
return [{ kind: "table", tableRows: readTableRows2(node, depth) }];
|
|
993
|
+
case "expand":
|
|
994
|
+
case "nestedExpand": {
|
|
995
|
+
const title = stringAttribute(node.attrs, "title").trim();
|
|
996
|
+
const prefix = title ? [{ kind: "paragraph", inlines: [{ text: title, isStrong: true }] }] : [];
|
|
997
|
+
return [...prefix, ...readBlocks2(content, depth)];
|
|
998
|
+
}
|
|
999
|
+
case "blockCard":
|
|
1000
|
+
case "embedCard": {
|
|
1001
|
+
const href = safeLinkHref(stringAttribute(node.attrs, "url"));
|
|
1002
|
+
return href ? [{ kind: "paragraph", inlines: [{ text: href, linkHref: href }] }] : [];
|
|
1003
|
+
}
|
|
1004
|
+
case "mediaSingle":
|
|
1005
|
+
case "mediaGroup":
|
|
1006
|
+
case "media":
|
|
1007
|
+
case "extension":
|
|
1008
|
+
return [];
|
|
1009
|
+
default:
|
|
1010
|
+
return readBlocks2(content, depth);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
function readList2(node, depth) {
|
|
1014
|
+
const kind = node.type === "orderedList" ? "orderedList" : node.type === "taskList" ? "taskList" : "bulletList";
|
|
1015
|
+
return { kind, orderedStart: numberAttribute(node.attrs, "order"), listItems: (node.content || []).map((item) => ({
|
|
1016
|
+
isTaskDone: stringAttribute(item.attrs, "state") === "DONE",
|
|
1017
|
+
blocks: item.type === "taskItem" || item.type === "decisionItem" ? appendParagraphBlock([], readInlines2(item.content || [])) : readBlocks2(item.content || [], depth)
|
|
1018
|
+
})) };
|
|
1019
|
+
}
|
|
1020
|
+
function readTableRows2(node, depth) {
|
|
1021
|
+
return (node.content || []).filter((row) => row.type === "tableRow").map((row) => ({
|
|
1022
|
+
isHeader: !!row.content?.length && row.content.every((cell) => cell.type === "tableHeader"),
|
|
1023
|
+
cells: (row.content || []).map((cell) => flattenBlocksToInlines(readBlocks2(cell.content || [], depth)))
|
|
1024
|
+
}));
|
|
1025
|
+
}
|
|
1026
|
+
function readInlines2(nodes) {
|
|
1027
|
+
let inlines = [];
|
|
1028
|
+
for (const node of nodes) inlines = appendADFInline(inlines, node);
|
|
1029
|
+
return inlines;
|
|
1030
|
+
}
|
|
1031
|
+
function appendADFInline(inlines, node) {
|
|
1032
|
+
const span = {};
|
|
1033
|
+
for (const mark of node.marks || []) {
|
|
1034
|
+
if (mark.type === "strong") span.isStrong = true;
|
|
1035
|
+
if (mark.type === "em") span.isEmphasis = true;
|
|
1036
|
+
if (mark.type === "code") span.isCode = true;
|
|
1037
|
+
if (mark.type === "strike") span.isStrikethrough = true;
|
|
1038
|
+
if (mark.type === "link") span.linkHref = safeLinkHref(stringAttribute(mark.attrs, "href"));
|
|
1039
|
+
}
|
|
1040
|
+
switch (node.type) {
|
|
1041
|
+
case "text":
|
|
1042
|
+
span.text = node.text || "";
|
|
1043
|
+
break;
|
|
1044
|
+
case "hardBreak":
|
|
1045
|
+
return appendInline(inlines, { isLineBreak: true });
|
|
1046
|
+
case "mention":
|
|
1047
|
+
case "status":
|
|
1048
|
+
span.text = stringAttribute(node.attrs, "text");
|
|
1049
|
+
break;
|
|
1050
|
+
case "emoji":
|
|
1051
|
+
span.text = stringAttribute(node.attrs, "text") || stringAttribute(node.attrs, "shortName");
|
|
1052
|
+
break;
|
|
1053
|
+
case "inlineCard":
|
|
1054
|
+
span.linkHref = safeLinkHref(stringAttribute(node.attrs, "url"));
|
|
1055
|
+
span.text = span.linkHref;
|
|
1056
|
+
break;
|
|
1057
|
+
case "date": {
|
|
1058
|
+
const timestamp = stringAttribute(node.attrs, "timestamp");
|
|
1059
|
+
span.text = formatADFDate(timestamp);
|
|
1060
|
+
break;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
return appendInline(inlines, span);
|
|
1064
|
+
}
|
|
1065
|
+
function stringAttribute(attributes, key) {
|
|
1066
|
+
const value = attributes?.[key];
|
|
1067
|
+
return typeof value === "string" ? value : "";
|
|
1068
|
+
}
|
|
1069
|
+
function numberAttribute(attributes, key) {
|
|
1070
|
+
const value = attributes?.[key];
|
|
1071
|
+
return typeof value === "number" ? value : 0;
|
|
1072
|
+
}
|
|
1073
|
+
function formatADFDate(timestamp) {
|
|
1074
|
+
if (!/^[+-]?\d+$/.test(timestamp)) return "";
|
|
1075
|
+
const milliseconds = BigInt(timestamp);
|
|
1076
|
+
if (milliseconds < -(1n << 63n) || milliseconds > (1n << 63n) - 1n) return "";
|
|
1077
|
+
let days = milliseconds / 86400000n;
|
|
1078
|
+
if (milliseconds < 0n && milliseconds % 86400000n !== 0n) days--;
|
|
1079
|
+
const eraDays = days + 719468n;
|
|
1080
|
+
const era = eraDays >= 0n ? eraDays / 146097n : (eraDays - 146096n) / 146097n;
|
|
1081
|
+
const dayOfEra = eraDays - era * 146097n;
|
|
1082
|
+
const yearOfEra = (dayOfEra - dayOfEra / 1460n + dayOfEra / 36524n - dayOfEra / 146096n) / 365n;
|
|
1083
|
+
let year = yearOfEra + era * 400n;
|
|
1084
|
+
const dayOfYear = dayOfEra - (365n * yearOfEra + yearOfEra / 4n - yearOfEra / 100n);
|
|
1085
|
+
const monthPosition = (5n * dayOfYear + 2n) / 153n;
|
|
1086
|
+
const day = dayOfYear - (153n * monthPosition + 2n) / 5n + 1n;
|
|
1087
|
+
const month = monthPosition + (monthPosition < 10n ? 3n : -9n);
|
|
1088
|
+
if (month <= 2n) year++;
|
|
1089
|
+
return `${year.toString().padStart(4, "0")}-${month.toString().padStart(2, "0")}-${day.toString().padStart(2, "0")}`;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
// src/time.ts
|
|
1093
|
+
function parseGoRFC3339(value) {
|
|
1094
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:[.,](\d+))?(Z|[+-]\d{2}:\d{2})$/.exec(value);
|
|
1095
|
+
if (!match) return void 0;
|
|
1096
|
+
const year = Number(match[1]), month = Number(match[2]), day = Number(match[3]);
|
|
1097
|
+
const hour = Number(match[4]), minute = Number(match[5]), second = Number(match[6]);
|
|
1098
|
+
if (month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month) || hour > 23 || minute > 59 || second > 59) return void 0;
|
|
1099
|
+
const zone = match[8];
|
|
1100
|
+
const zoneHours = zone === "Z" ? 0 : Number(zone.slice(1, 3));
|
|
1101
|
+
const zoneMinutes = zone === "Z" ? 0 : Number(zone.slice(4, 6));
|
|
1102
|
+
if (zoneMinutes > 59) return void 0;
|
|
1103
|
+
const offsetMinutes = (zone.startsWith("-") ? -1 : 1) * (zoneHours * 60 + zoneMinutes);
|
|
1104
|
+
const fraction = (match[7] || "").slice(0, 9).padEnd(9, "0");
|
|
1105
|
+
const calendar = /* @__PURE__ */ new Date(0);
|
|
1106
|
+
calendar.setUTCFullYear(year, month - 1, day);
|
|
1107
|
+
calendar.setUTCHours(hour, minute, second, Number(fraction.slice(0, 3)));
|
|
1108
|
+
const epochMs = calendar.getTime() - offsetMinutes * 6e4;
|
|
1109
|
+
if (!Number.isFinite(epochMs)) return void 0;
|
|
1110
|
+
const canonicalFraction = fraction.replace(/0+$/, "");
|
|
1111
|
+
const canonicalZone = zone === "Z" || offsetMinutes === 0 ? "Z" : zone;
|
|
1112
|
+
const canonical = value.slice(0, 19) + (canonicalFraction ? `.${canonicalFraction}` : "") + canonicalZone;
|
|
1113
|
+
return { canonical, epochMs };
|
|
1114
|
+
}
|
|
1115
|
+
function daysInMonth(year, month) {
|
|
1116
|
+
if ([4, 6, 9, 11].includes(month)) return 30;
|
|
1117
|
+
if (month === 2) return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0) ? 29 : 28;
|
|
1118
|
+
return 31;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
// src/operations.ts
|
|
1122
|
+
var emptyTime = "0001-01-01T00:00:00Z";
|
|
1123
|
+
var idPattern = /^[1-9][0-9]{0,18}$/;
|
|
1124
|
+
var spaceKeyPattern = /^~?[A-Za-z0-9_-]{1,255}$/;
|
|
1125
|
+
var SearchPagesOperation = class {
|
|
1126
|
+
/** Bind the client. */
|
|
1127
|
+
constructor(client) {
|
|
1128
|
+
this.client = client;
|
|
1129
|
+
}
|
|
1130
|
+
client;
|
|
1131
|
+
/** Return the stable definition. */
|
|
1132
|
+
definition() {
|
|
1133
|
+
return SearchPagesDefinition;
|
|
1134
|
+
}
|
|
1135
|
+
/** Execute one authenticated search. */
|
|
1136
|
+
async invoke(call, input) {
|
|
1137
|
+
const operation = "searchPages";
|
|
1138
|
+
let cql;
|
|
1139
|
+
try {
|
|
1140
|
+
cql = buildCql(input.filter);
|
|
1141
|
+
} catch (error) {
|
|
1142
|
+
return newQueryBranch("defect", { cql: "", pages: [] }, zeroReceipt(), confluenceFailure(operation, "VALIDATION", errorMessage(error)));
|
|
1143
|
+
}
|
|
1144
|
+
const pageSize = input.pageSize || 25;
|
|
1145
|
+
if (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > 100) return newQueryBranch("defect", { cql: "", pages: [] }, zeroReceipt(), confluenceFailure(operation, "VALIDATION", "pageSize must be between 1 and 100"));
|
|
1146
|
+
const cursor = (input.cursor || "").trim();
|
|
1147
|
+
if (cursor && !isCursor(cursor)) return newQueryBranch("defect", { cql: "", pages: [] }, zeroReceipt(), confluenceFailure(operation, "VALIDATION", "cursor must be the printable cursor from a previous search page"));
|
|
1148
|
+
const output = { cql, pages: [] };
|
|
1149
|
+
const started = await this.client.startSession(call, operation);
|
|
1150
|
+
if ("error" in started) return started.error.isRetryable ? newQueryRetry(started.error.failure, started.error.retryAfterMs) : newQueryBranch("defect", output, zeroReceipt(), started.error.failure);
|
|
1151
|
+
const session = started.session;
|
|
1152
|
+
const response = await this.client.exchange(session, "GET", "search", "/content/search", { cql, limit: String(pageSize), expand: "space,version", ...cursor ? { cursor } : {} });
|
|
1153
|
+
const classification = this.client.classifyRead(operation, "page search", response);
|
|
1154
|
+
const receipt = this.client.receipt(session, response);
|
|
1155
|
+
if (classification.outcome === "retry") return newQueryRetry(classification.failure, classification.retryAfterMs);
|
|
1156
|
+
if (classification.outcome !== "accepted") return newQueryBranch(classification.outcome === "invalid" ? "invalidResponse" : classification.outcome === "defect" ? "defect" : "providerRejected", output, receipt, classification.failure);
|
|
1157
|
+
let decoded;
|
|
1158
|
+
try {
|
|
1159
|
+
decoded = decodeObject(response);
|
|
1160
|
+
} catch {
|
|
1161
|
+
return newQueryBranch("invalidResponse", output, receipt, confluenceFailure(operation, "PROTOCOL", "Confluence returned an invalid search page"));
|
|
1162
|
+
}
|
|
1163
|
+
const links = objectField(decoded, "_links");
|
|
1164
|
+
const nextLink = stringField(links, "next");
|
|
1165
|
+
if (nextLink) {
|
|
1166
|
+
try {
|
|
1167
|
+
const nextCursor = new URL(nextLink, "https://confluence.invalid").searchParams.get("cursor") || "";
|
|
1168
|
+
if (!isCursor(nextCursor)) throw new TypeError();
|
|
1169
|
+
output.nextCursor = nextCursor;
|
|
1170
|
+
} catch {
|
|
1171
|
+
return newQueryBranch("invalidResponse", output, receipt, confluenceFailure(operation, "PROTOCOL", "Confluence returned an invalid search cursor"));
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
const results = decoded.results;
|
|
1175
|
+
if (results !== void 0 && !Array.isArray(results)) return newQueryBranch("invalidResponse", { cql, pages: [] }, receipt, confluenceFailure(operation, "PROTOCOL", "Confluence returned an invalid search page"));
|
|
1176
|
+
for (const resource of results || []) {
|
|
1177
|
+
try {
|
|
1178
|
+
const summary = decodePageSummary(resource, stringField(links, "base"));
|
|
1179
|
+
if (summary && (!input.filter.modifiedSince || summary.lastModifiedAt === emptyTime || parseGoRFC3339(summary.lastModifiedAt).epochMs >= parseGoRFC3339(input.filter.modifiedSince).epochMs)) output.pages.push(summary);
|
|
1180
|
+
} catch (error) {
|
|
1181
|
+
return newQueryBranch("invalidResponse", { cql, pages: [] }, receipt, confluenceFailure(operation, "PROTOCOL", "Confluence returned an invalid page in the search results: " + errorMessage(error)));
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
return newQueryBranch("searched", output, receipt);
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
var GetPageOperation = class {
|
|
1188
|
+
/** Bind the client. */
|
|
1189
|
+
constructor(client) {
|
|
1190
|
+
this.client = client;
|
|
1191
|
+
}
|
|
1192
|
+
client;
|
|
1193
|
+
/** Return the stable definition. */
|
|
1194
|
+
definition() {
|
|
1195
|
+
return GetPageDefinition;
|
|
1196
|
+
}
|
|
1197
|
+
/** Execute one page read. */
|
|
1198
|
+
async invoke(call, input) {
|
|
1199
|
+
const operation = "getPage";
|
|
1200
|
+
let pageId;
|
|
1201
|
+
try {
|
|
1202
|
+
pageId = validateId(input.pageId, "pageId");
|
|
1203
|
+
} catch (error) {
|
|
1204
|
+
return newQueryBranch("defect", emptyPage(), zeroReceipt(), confluenceFailure(operation, "VALIDATION", errorMessage(error)));
|
|
1205
|
+
}
|
|
1206
|
+
const representation = input.bodyRepresentation || "storage";
|
|
1207
|
+
if (representation !== "storage" && representation !== "atlas_doc_format") return newQueryBranch("defect", emptyPage(), zeroReceipt(), confluenceFailure(operation, "VALIDATION", "bodyRepresentation must be storage or atlas_doc_format"));
|
|
1208
|
+
const format = input.bodyFormat || "markdown";
|
|
1209
|
+
if (format !== "markdown" && format !== "plainText") return newQueryBranch("defect", emptyPage(), zeroReceipt(), confluenceFailure(operation, "VALIDATION", "bodyFormat must be markdown or plainText"));
|
|
1210
|
+
const maxCharacters = input.maxBodyCharacters || 32768;
|
|
1211
|
+
if (!Number.isInteger(maxCharacters) || maxCharacters < 1 || maxCharacters > 131072) return newQueryBranch("defect", emptyPage(), zeroReceipt(), confluenceFailure(operation, "VALIDATION", "maxBodyCharacters must be between 1 and 131072"));
|
|
1212
|
+
const started = await this.client.startSession(call, operation);
|
|
1213
|
+
if ("error" in started) return started.error.isRetryable ? newQueryRetry(started.error.failure, started.error.retryAfterMs) : newQueryBranch("defect", emptyPage(), zeroReceipt(), started.error.failure);
|
|
1214
|
+
const session = started.session;
|
|
1215
|
+
const response = await this.client.exchange(session, "GET", "content", `/pages/${pathEscape(pageId)}`, { "body-format": representation });
|
|
1216
|
+
const classification = this.client.classifyRead(operation, "page read", response);
|
|
1217
|
+
const receipt = this.client.receipt(session, response, pageId);
|
|
1218
|
+
if (classification.outcome === "retry") return newQueryRetry(classification.failure, classification.retryAfterMs);
|
|
1219
|
+
if (classification.outcome !== "accepted") return newQueryBranch(classification.outcome === "notFound" ? "notFound" : classification.outcome === "invalid" ? "invalidResponse" : classification.outcome === "defect" ? "defect" : "providerRejected", emptyPage(), receipt, classification.failure);
|
|
1220
|
+
let decoded;
|
|
1221
|
+
try {
|
|
1222
|
+
decoded = decodeObject(response);
|
|
1223
|
+
} catch {
|
|
1224
|
+
return newQueryBranch("invalidResponse", emptyPage(), receipt, confluenceFailure(operation, "PROTOCOL", "Confluence returned an invalid page"));
|
|
1225
|
+
}
|
|
1226
|
+
try {
|
|
1227
|
+
return newQueryBranch("found", decodePage(decoded, representation, format, maxCharacters), receipt);
|
|
1228
|
+
} catch (error) {
|
|
1229
|
+
return newQueryBranch("invalidResponse", emptyPage(), receipt, confluenceFailure(operation, "PROTOCOL", "Confluence returned an unreadable page: " + errorMessage(error)));
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1233
|
+
var CreatePageOperation = class {
|
|
1234
|
+
/** Bind the client. */
|
|
1235
|
+
constructor(client) {
|
|
1236
|
+
this.client = client;
|
|
1237
|
+
}
|
|
1238
|
+
client;
|
|
1239
|
+
/** Return the stable definition. */
|
|
1240
|
+
definition() {
|
|
1241
|
+
return CreatePageDefinition;
|
|
1242
|
+
}
|
|
1243
|
+
/** Derive the stable Dex idempotency key. */
|
|
1244
|
+
idempotencyKey(callId) {
|
|
1245
|
+
return callId;
|
|
1246
|
+
}
|
|
1247
|
+
/** Execute one create with read-back reconciliation. */
|
|
1248
|
+
async invoke(call, input) {
|
|
1249
|
+
const operation = "createPage";
|
|
1250
|
+
const requested = { title: (input.title || "").trim() };
|
|
1251
|
+
const spaceId = (input.spaceId || "").trim(), spaceKey = (input.spaceKey || "").trim(), parentId = (input.parentPageId || "").trim();
|
|
1252
|
+
if (spaceId) requested.spaceId = spaceId;
|
|
1253
|
+
if (spaceKey) requested.spaceKey = spaceKey;
|
|
1254
|
+
if (parentId) requested.parentPageId = parentId;
|
|
1255
|
+
let storage, comparisonText;
|
|
1256
|
+
try {
|
|
1257
|
+
if (!!spaceId === !!spaceKey) throw new TypeError("set exactly one of spaceId and spaceKey");
|
|
1258
|
+
if (spaceId && !idPattern.test(spaceId)) throw new TypeError("spaceId must be a numeric Confluence space ID");
|
|
1259
|
+
if (spaceKey && !spaceKeyPattern.test(spaceKey)) throw new TypeError("spaceKey must be a space key such as OPS");
|
|
1260
|
+
if (parentId && !idPattern.test(parentId)) throw new TypeError("parentPageId must be a numeric Confluence page ID");
|
|
1261
|
+
requested.title = validateTitle(input.title);
|
|
1262
|
+
({ storage, comparisonText } = convertWrittenBody(input.body, input.bodyFormat, "body"));
|
|
1263
|
+
} catch (error) {
|
|
1264
|
+
return newMutationBranch("defect", requested, zeroReceipt(), confluenceFailure(operation, "VALIDATION", errorMessage(error)));
|
|
1265
|
+
}
|
|
1266
|
+
const started = await this.client.startSession(call, operation);
|
|
1267
|
+
if ("error" in started) return started.error.isRetryable ? newMutationRetry(started.error.failure, started.error.retryAfterMs) : newMutationBranch("defect", requested, zeroReceipt(), started.error.failure);
|
|
1268
|
+
const session = started.session;
|
|
1269
|
+
if (!spaceId) {
|
|
1270
|
+
const resolved = await resolveSpaceId(this.client, session, operation, spaceKey);
|
|
1271
|
+
if ("classification" in resolved) {
|
|
1272
|
+
const state2 = resolved.classification;
|
|
1273
|
+
if (state2.outcome === "retry") return newMutationRetry(state2.failure, state2.retryAfterMs);
|
|
1274
|
+
const branch = state2.outcome === "notFound" ? "notFound" : state2.outcome === "defect" ? "defect" : "providerRejected";
|
|
1275
|
+
return newMutationBranch(branch, requested, this.client.receipt(session, emptyResponse()), state2.failure);
|
|
1276
|
+
}
|
|
1277
|
+
requested.spaceId = resolved.spaceId;
|
|
1278
|
+
}
|
|
1279
|
+
const body = { spaceId: requested.spaceId, status: "current", title: requested.title, ...parentId ? { parentId } : {}, body: { representation: "storage", value: storage } };
|
|
1280
|
+
const earliestSendAt = earliestDispatchTime(call, this.client.now());
|
|
1281
|
+
const checkpoint = readDispatchCheckpoint(call);
|
|
1282
|
+
const firstSendAt = checkpoint ? Math.min(earliestSendAt, checkpoint.dispatchedAt || earliestSendAt) : earliestSendAt;
|
|
1283
|
+
if (checkpoint) {
|
|
1284
|
+
const lookup2 = await findPageByTitle(this.client, session, operation, body.spaceId, body.title);
|
|
1285
|
+
const decided = this.reconcileByTitle(session, requested, comparisonText, parentId, firstSendAt, lookup2);
|
|
1286
|
+
if (decided) return decided;
|
|
1287
|
+
}
|
|
1288
|
+
try {
|
|
1289
|
+
await call.context.recordHeartbeat({ dispatchedAtUnixMilli: firstSendAt });
|
|
1290
|
+
} catch {
|
|
1291
|
+
return newMutationRetry(confluenceFailure(operation, "AVAILABILITY", "the create checkpoint could not be recorded, so nothing was sent to Confluence"));
|
|
1292
|
+
}
|
|
1293
|
+
const response = await this.client.exchange(session, "POST", "content", "/pages", void 0, body);
|
|
1294
|
+
let state = this.client.classifyWrite(operation, "page", response);
|
|
1295
|
+
const receipt = this.client.receipt(session, response);
|
|
1296
|
+
if (state.outcome === "accepted") {
|
|
1297
|
+
try {
|
|
1298
|
+
const resource = decodeObject(response);
|
|
1299
|
+
validatePageResource(resource);
|
|
1300
|
+
return newMutationBranch("created", createdOutput(requested, resource, "", false), this.client.receipt(session, response, stringField(resource, "id")));
|
|
1301
|
+
} catch {
|
|
1302
|
+
state = { outcome: "ambiguous", failure: confluenceFailure(operation, "PROTOCOL", "Confluence accepted the page but returned an unusable page"), retryAfterMs: 0 };
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
if (state.outcome === "notApplied") {
|
|
1306
|
+
clearDispatchCheckpoint(call);
|
|
1307
|
+
return newMutationRetry(state.failure, state.retryAfterMs);
|
|
1308
|
+
}
|
|
1309
|
+
if (state.outcome === "notFound") return newMutationBranch("notFound", requested, receipt, state.failure);
|
|
1310
|
+
if (state.outcome === "defect") {
|
|
1311
|
+
clearDispatchCheckpoint(call);
|
|
1312
|
+
return newMutationBranch("defect", requested, receipt, state.failure);
|
|
1313
|
+
}
|
|
1314
|
+
if (state.outcome === "rejected") {
|
|
1315
|
+
if (response.status !== 400 && response.status !== 409) return newMutationBranch("providerRejected", requested, receipt, state.failure);
|
|
1316
|
+
const lookup2 = await findPageByTitle(this.client, session, operation, body.spaceId, body.title);
|
|
1317
|
+
const decided = this.reconcileByTitle(session, requested, comparisonText, parentId, firstSendAt, lookup2);
|
|
1318
|
+
return decided || newMutationBranch("providerRejected", requested, receipt, state.failure);
|
|
1319
|
+
}
|
|
1320
|
+
const lookup = await findPageByTitle(this.client, session, operation, body.spaceId, body.title);
|
|
1321
|
+
if (lookup.page) {
|
|
1322
|
+
const decided = this.reconcileByTitle(session, requested, comparisonText, parentId, firstSendAt, lookup);
|
|
1323
|
+
if (decided) return decided;
|
|
1324
|
+
}
|
|
1325
|
+
return newMutationRetry(state.failure, Math.max(state.retryAfterMs, 5e3));
|
|
1326
|
+
}
|
|
1327
|
+
reconcileByTitle(session, requested, comparisonText, parentId, earliestSendAt, lookup) {
|
|
1328
|
+
const operation = "createPage";
|
|
1329
|
+
const state = lookup.classification;
|
|
1330
|
+
if (state.outcome === "notFound") return newMutationBranch("notFound", requested, this.client.receipt(session, lookup.response), state.failure);
|
|
1331
|
+
if (state.outcome === "rejected") return void 0;
|
|
1332
|
+
if (state.outcome !== "accepted") return newMutationRetry({ ...state.failure, message: "an earlier create may have reached Confluence and its page could not be looked up: " + state.failure.message }, Math.max(state.retryAfterMs, 5e3));
|
|
1333
|
+
if (!lookup.page) return void 0;
|
|
1334
|
+
const page = lookup.page;
|
|
1335
|
+
const output = createdOutput(requested, page, lookup.siteBase, false);
|
|
1336
|
+
const receipt = this.client.receipt(session, lookup.response, stringField(page, "id"));
|
|
1337
|
+
const createdAt = parseGoRFC3339(stringField(page, "createdAt"))?.epochMs;
|
|
1338
|
+
const body = objectField(objectField(page, "body"), "storage");
|
|
1339
|
+
const matches = createdAt !== void 0 && createdAt >= earliestSendAt - 6e4 && (!parentId || stringField(page, "parentId") === parentId) && storageComparisonText(stringField(body, "value")) === comparisonText;
|
|
1340
|
+
if (matches) return newMutationBranch("created", { ...output, isConfirmedByTitleLookup: true }, receipt);
|
|
1341
|
+
return newMutationBranch("titleConflict", output, receipt, confluenceFailure(operation, "CONFLICT", "another page in the space already has this title, so nothing was created"));
|
|
1342
|
+
}
|
|
1343
|
+
};
|
|
1344
|
+
var UpdatePageOperation = class {
|
|
1345
|
+
/** Bind the client. */
|
|
1346
|
+
constructor(client) {
|
|
1347
|
+
this.client = client;
|
|
1348
|
+
}
|
|
1349
|
+
client;
|
|
1350
|
+
/** Return the stable definition. */
|
|
1351
|
+
definition() {
|
|
1352
|
+
return UpdatePageDefinition;
|
|
1353
|
+
}
|
|
1354
|
+
/** Derive the stable Dex idempotency key. */
|
|
1355
|
+
idempotencyKey(callId) {
|
|
1356
|
+
return callId;
|
|
1357
|
+
}
|
|
1358
|
+
/** Execute one update with version reconciliation. */
|
|
1359
|
+
async invoke(call, input) {
|
|
1360
|
+
const operation = "updatePage";
|
|
1361
|
+
const requested = { pageId: (input.pageId || "").trim(), title: (input.title || "").trim() };
|
|
1362
|
+
let pageId, marker, body;
|
|
1363
|
+
try {
|
|
1364
|
+
pageId = validateId(input.pageId, "pageId");
|
|
1365
|
+
requested.title = validateTitle(input.title);
|
|
1366
|
+
if (!Number.isInteger(input.nextVersionNumber) || input.nextVersionNumber < 2) throw new TypeError("nextVersionNumber must be the page's current version number plus one, at least 2");
|
|
1367
|
+
const message = (input.versionMessage || "").trim();
|
|
1368
|
+
if ([...message].length > 200) throw new TypeError("versionMessage cannot exceed 200 characters");
|
|
1369
|
+
if (hasControlCharacter(message)) throw new TypeError("versionMessage must be one line without control characters");
|
|
1370
|
+
const { storage } = convertWrittenBody(input.body, input.bodyFormat, "body");
|
|
1371
|
+
marker = "dex:" + createHash("sha256").update(call.idempotencyKey || call.id).digest("hex").slice(0, 16);
|
|
1372
|
+
body = { id: pageId, status: "current", title: requested.title, body: { representation: "storage", value: storage }, version: { number: input.nextVersionNumber, message: (message ? message + " " : "") + `[${marker}]` } };
|
|
1373
|
+
} catch (error) {
|
|
1374
|
+
return newMutationBranch("defect", requested, zeroReceipt(), confluenceFailure(operation, "VALIDATION", errorMessage(error)));
|
|
1375
|
+
}
|
|
1376
|
+
const started = await this.client.startSession(call, operation);
|
|
1377
|
+
if ("error" in started) return started.error.isRetryable ? newMutationRetry(started.error.failure, started.error.retryAfterMs) : newMutationBranch("defect", requested, zeroReceipt(), started.error.failure);
|
|
1378
|
+
const session = started.session;
|
|
1379
|
+
const response = await this.client.exchange(session, "PUT", "content", `/pages/${pathEscape(pageId)}`, void 0, body);
|
|
1380
|
+
let classification = this.client.classifyWrite(operation, "page update", response);
|
|
1381
|
+
const receipt = this.client.receipt(session, response, pageId);
|
|
1382
|
+
if (classification.outcome === "accepted") {
|
|
1383
|
+
try {
|
|
1384
|
+
const page = decodeObject(response);
|
|
1385
|
+
validatePageResource(page);
|
|
1386
|
+
if (numberField(objectField(page, "version"), "number") !== input.nextVersionNumber) throw new TypeError();
|
|
1387
|
+
return newMutationBranch("updated", updatedOutput(requested, page, "", false), receipt);
|
|
1388
|
+
} catch {
|
|
1389
|
+
classification = { outcome: "ambiguous", failure: confluenceFailure(operation, "PROTOCOL", "Confluence accepted the update but returned an unusable page"), retryAfterMs: 0 };
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
if (classification.outcome === "notApplied") return newMutationRetry(classification.failure, classification.retryAfterMs);
|
|
1393
|
+
if (classification.outcome === "notFound") return newMutationBranch("notFound", requested, receipt, classification.failure);
|
|
1394
|
+
if (classification.outcome === "defect") return newMutationBranch("defect", requested, receipt, classification.failure);
|
|
1395
|
+
if (classification.outcome === "rejected" && response.status !== 400 && response.status !== 409) return newMutationBranch("providerRejected", requested, receipt, classification.failure);
|
|
1396
|
+
const lookup = await readPage(this.client, session, operation, pageId);
|
|
1397
|
+
const readBack = await this.reportReadBack(session, requested, input.nextVersionNumber, marker, lookup);
|
|
1398
|
+
if (readBack) return readBack;
|
|
1399
|
+
if (classification.outcome === "rejected") return newMutationBranch("providerRejected", requested, this.client.receipt(session, lookup.response, pageId), classification.failure);
|
|
1400
|
+
return newMutationRetry(classification.failure, Math.max(classification.retryAfterMs, 5e3));
|
|
1401
|
+
}
|
|
1402
|
+
async reportReadBack(session, requested, nextVersion, marker, lookup) {
|
|
1403
|
+
const operation = "updatePage";
|
|
1404
|
+
const receipt = this.client.receipt(session, lookup.response, requested.pageId);
|
|
1405
|
+
const classification = lookup.classification;
|
|
1406
|
+
if (classification.outcome === "notFound") return newMutationBranch("notFound", requested, receipt, classification.failure);
|
|
1407
|
+
if (classification.outcome !== "accepted") return newMutationRetry({ ...classification.failure, message: "the update outcome is unknown and the page could not be read back: " + classification.failure.message }, Math.max(classification.retryAfterMs, 5e3));
|
|
1408
|
+
const page = lookup.page;
|
|
1409
|
+
const version = objectField(page, "version"), current = numberField(version, "number");
|
|
1410
|
+
if (current === nextVersion && stringField(version, "message").includes(marker)) return newMutationBranch("updated", updatedOutput(requested, page, lookup.siteBase, true), receipt);
|
|
1411
|
+
if (current === nextVersion - 1) return void 0;
|
|
1412
|
+
if (current > nextVersion) {
|
|
1413
|
+
const response = await this.client.exchange(session, "GET", "content", `/pages/${pathEscape(requested.pageId)}/versions/${nextVersion}`);
|
|
1414
|
+
const state = this.client.classifyRead(operation, "page version", response);
|
|
1415
|
+
if (state.outcome === "retry") return newMutationRetry(state.failure, state.retryAfterMs);
|
|
1416
|
+
if (state.outcome === "accepted") {
|
|
1417
|
+
try {
|
|
1418
|
+
const oldVersion = decodeObject(response);
|
|
1419
|
+
if (numberField(oldVersion, "number") === nextVersion && stringField(oldVersion, "message").includes(marker)) return newMutationBranch("updated", { ...updatedOutput(requested, page, lookup.siteBase, true), versionNumber: nextVersion }, receipt);
|
|
1420
|
+
} catch {
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
return newMutationBranch("versionConflict", updatedOutput(requested, page, lookup.siteBase, false), receipt, confluenceFailure(operation, "CONFLICT", "the page is no longer at the version before nextVersionNumber, so nothing was changed"));
|
|
1425
|
+
}
|
|
1426
|
+
};
|
|
1427
|
+
var AddCommentOperation = class {
|
|
1428
|
+
/** Bind the client. */
|
|
1429
|
+
constructor(client) {
|
|
1430
|
+
this.client = client;
|
|
1431
|
+
}
|
|
1432
|
+
client;
|
|
1433
|
+
/** Return the stable definition. */
|
|
1434
|
+
definition() {
|
|
1435
|
+
return AddCommentDefinition;
|
|
1436
|
+
}
|
|
1437
|
+
/** Derive the stable Dex idempotency key. */
|
|
1438
|
+
idempotencyKey(callId) {
|
|
1439
|
+
return callId;
|
|
1440
|
+
}
|
|
1441
|
+
/** Execute one comment send or read-back. */
|
|
1442
|
+
async invoke(call, input) {
|
|
1443
|
+
const operation = "addComment";
|
|
1444
|
+
const requested = { pageId: (input.pageId || "").trim(), createdAt: emptyTime };
|
|
1445
|
+
let pageId, storage, comparisonText;
|
|
1446
|
+
try {
|
|
1447
|
+
pageId = validateId(input.pageId, "pageId");
|
|
1448
|
+
({ storage, comparisonText } = convertWrittenBody(input.body, input.bodyFormat, "body"));
|
|
1449
|
+
} catch (error) {
|
|
1450
|
+
return newMutationBranch("defect", requested, zeroReceipt(), confluenceFailure(operation, "VALIDATION", errorMessage(error)));
|
|
1451
|
+
}
|
|
1452
|
+
const started = await this.client.startSession(call, operation);
|
|
1453
|
+
if ("error" in started) return started.error.isRetryable ? newMutationRetry(started.error.failure, started.error.retryAfterMs) : newMutationBranch("defect", requested, zeroReceipt(), started.error.failure);
|
|
1454
|
+
const session = started.session;
|
|
1455
|
+
const checkpoint = readDispatchCheckpoint(call);
|
|
1456
|
+
const earliestSendAt = earliestDispatchTime(call, this.client.now());
|
|
1457
|
+
if (checkpoint) return this.reconcileEarlierDispatch(session, requested, comparisonText, Math.min(earliestSendAt, checkpoint.dispatchedAt || earliestSendAt));
|
|
1458
|
+
try {
|
|
1459
|
+
await call.context.recordHeartbeat({ dispatchedAtUnixMilli: earliestSendAt });
|
|
1460
|
+
} catch {
|
|
1461
|
+
return newMutationRetry(confluenceFailure(operation, "AVAILABILITY", "the comment checkpoint could not be recorded, so nothing was sent to Confluence"));
|
|
1462
|
+
}
|
|
1463
|
+
const response = await this.client.exchange(session, "POST", "content", "/footer-comments", void 0, { pageId, body: { representation: "storage", value: storage } });
|
|
1464
|
+
let classification = this.client.classifyWrite(operation, "comment", response);
|
|
1465
|
+
const receipt = this.client.receipt(session, response);
|
|
1466
|
+
if (classification.outcome === "accepted") {
|
|
1467
|
+
try {
|
|
1468
|
+
const comment = decodeObject(response);
|
|
1469
|
+
const id = stringField(comment, "id");
|
|
1470
|
+
if (idPattern.test(id)) return newMutationBranch("added", addedCommentOutput(requested, comment, false), this.client.receipt(session, response, id));
|
|
1471
|
+
} catch {
|
|
1472
|
+
}
|
|
1473
|
+
classification = { outcome: "ambiguous", failure: confluenceFailure(operation, "PROTOCOL", "Confluence accepted the comment but returned an unusable comment"), retryAfterMs: 0 };
|
|
1474
|
+
}
|
|
1475
|
+
if (classification.outcome === "notApplied") {
|
|
1476
|
+
clearDispatchCheckpoint(call);
|
|
1477
|
+
return newMutationRetry(classification.failure, classification.retryAfterMs);
|
|
1478
|
+
}
|
|
1479
|
+
if (classification.outcome === "notFound") return newMutationBranch("notFound", requested, receipt, classification.failure);
|
|
1480
|
+
if (classification.outcome === "rejected") return newMutationBranch("providerRejected", requested, receipt, classification.failure);
|
|
1481
|
+
if (classification.outcome === "defect") {
|
|
1482
|
+
clearDispatchCheckpoint(call);
|
|
1483
|
+
return newMutationBranch("defect", requested, receipt, classification.failure);
|
|
1484
|
+
}
|
|
1485
|
+
return newMutationRetry(classification.failure, Math.max(classification.retryAfterMs, 5e3));
|
|
1486
|
+
}
|
|
1487
|
+
async reconcileEarlierDispatch(session, requested, comparisonText, earliestSendAt) {
|
|
1488
|
+
const operation = "addComment";
|
|
1489
|
+
const response = await this.client.exchange(session, "GET", "content", `/pages/${pathEscape(requested.pageId)}/footer-comments`, { "body-format": "storage", sort: "-created-date", limit: "25" });
|
|
1490
|
+
const classification = this.client.classifyRead(operation, "page comments", response);
|
|
1491
|
+
const receipt = this.client.receipt(session, response);
|
|
1492
|
+
if (classification.outcome === "retry") return newMutationRetry(classification.failure, classification.retryAfterMs);
|
|
1493
|
+
if (classification.outcome === "notFound") return newMutationBranch("notFound", requested, receipt, classification.failure);
|
|
1494
|
+
if (classification.outcome !== "accepted") return newMutationUncertain(requested, { ...classification.failure, message: "an earlier attempt of this Step sent the comment, and the page's comments could not be read back: " + classification.failure.message }, receipt);
|
|
1495
|
+
let results;
|
|
1496
|
+
try {
|
|
1497
|
+
const decoded = decodeObject(response);
|
|
1498
|
+
if (!Array.isArray(decoded.results)) throw new TypeError();
|
|
1499
|
+
results = decoded.results;
|
|
1500
|
+
} catch {
|
|
1501
|
+
return newMutationUncertain(requested, confluenceFailure(operation, "PROTOCOL", "an earlier attempt of this Step sent the comment, and the page's comments read back are invalid"), receipt);
|
|
1502
|
+
}
|
|
1503
|
+
for (const value of results) {
|
|
1504
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) continue;
|
|
1505
|
+
const comment = value;
|
|
1506
|
+
try {
|
|
1507
|
+
const id = stringField(comment, "id"), version = objectField(comment, "version"), body = objectField(objectField(comment, "body"), "storage");
|
|
1508
|
+
const createdAt = parseGoRFC3339(stringField(version, "createdAt"))?.epochMs;
|
|
1509
|
+
if (idPattern.test(id) && createdAt !== void 0 && createdAt >= earliestSendAt - 6e4 && storageComparisonText(stringField(body, "value")) === comparisonText) return newMutationBranch("added", addedCommentOutput(requested, comment, true), this.client.receipt(session, response, id));
|
|
1510
|
+
} catch {
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
return newMutationUncertain(requested, confluenceFailure(operation, "TRANSPORT", "an earlier attempt of this Step sent the comment without a confirmed outcome, and the page shows no matching comment, so it is not sent again"), receipt);
|
|
1514
|
+
}
|
|
1515
|
+
};
|
|
1516
|
+
function errorMessage(error) {
|
|
1517
|
+
return error instanceof Error ? error.message : "invalid input";
|
|
1518
|
+
}
|
|
1519
|
+
function objectField(object, key) {
|
|
1520
|
+
const value = object[key];
|
|
1521
|
+
if (value == null) return {};
|
|
1522
|
+
if (typeof value !== "object" || Array.isArray(value)) throw new TypeError(`${key} has an invalid type`);
|
|
1523
|
+
return value;
|
|
1524
|
+
}
|
|
1525
|
+
function stringField(object, key) {
|
|
1526
|
+
const value = object[key];
|
|
1527
|
+
if (value !== void 0 && typeof value !== "string") throw new TypeError(`${key} has an invalid type`);
|
|
1528
|
+
return value || "";
|
|
1529
|
+
}
|
|
1530
|
+
function numberField(object, key) {
|
|
1531
|
+
const value = object[key];
|
|
1532
|
+
if (value !== void 0 && (typeof value !== "number" || !Number.isInteger(value))) throw new TypeError(`${key} has an invalid type`);
|
|
1533
|
+
return value || 0;
|
|
1534
|
+
}
|
|
1535
|
+
function isCursor(value) {
|
|
1536
|
+
return !!value && Buffer.byteLength(value) <= 4096 && /^[\x21-\x7e]+$/.test(value);
|
|
1537
|
+
}
|
|
1538
|
+
function validateId(value, field) {
|
|
1539
|
+
const trimmed = value.trim();
|
|
1540
|
+
if (!idPattern.test(trimmed)) throw new TypeError(`${field} must be a numeric Confluence content ID`);
|
|
1541
|
+
return trimmed;
|
|
1542
|
+
}
|
|
1543
|
+
function emptyPage() {
|
|
1544
|
+
return { id: "", title: "", status: "", spaceId: "", createdAt: emptyTime, version: { number: 0, createdAt: emptyTime }, body: "", bodyFormat: "" };
|
|
1545
|
+
}
|
|
1546
|
+
function webURL(base, path) {
|
|
1547
|
+
if (!base.startsWith("https://") || !/^\/[\x21-\x7e]*$/.test(path)) return "";
|
|
1548
|
+
try {
|
|
1549
|
+
const parsed = new URL(base);
|
|
1550
|
+
if (parsed.username || parsed.password || parsed.search || parsed.hash) return "";
|
|
1551
|
+
} catch {
|
|
1552
|
+
return "";
|
|
1553
|
+
}
|
|
1554
|
+
const url = base.replace(/\/+$/, "") + path;
|
|
1555
|
+
return Buffer.byteLength(url) <= 2048 ? url : "";
|
|
1556
|
+
}
|
|
1557
|
+
function decodePageSummary(value, base) {
|
|
1558
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("page resource is invalid");
|
|
1559
|
+
const resource = value;
|
|
1560
|
+
if (stringField(resource, "type") !== "page") return void 0;
|
|
1561
|
+
const id = stringField(resource, "id");
|
|
1562
|
+
const title = stringField(resource, "title");
|
|
1563
|
+
if (!idPattern.test(id) || !title) throw new TypeError("page ID or title is missing");
|
|
1564
|
+
const summary = { id, title, lastModifiedAt: emptyTime };
|
|
1565
|
+
const status = stringField(resource, "status");
|
|
1566
|
+
if (status) summary.status = status;
|
|
1567
|
+
const links = objectField(resource, "_links");
|
|
1568
|
+
const url = webURL(base, stringField(links, "webui"));
|
|
1569
|
+
if (url) summary.webUrl = url;
|
|
1570
|
+
const space = objectField(resource, "space");
|
|
1571
|
+
if (space.id !== void 0) {
|
|
1572
|
+
const spaceId = typeof space.id === "number" ? String(space.id) : stringField(space, "id");
|
|
1573
|
+
if (idPattern.test(spaceId)) summary.spaceId = spaceId;
|
|
1574
|
+
}
|
|
1575
|
+
const spaceKey = stringField(space, "key");
|
|
1576
|
+
if (spaceKeyPattern.test(spaceKey)) summary.spaceKey = spaceKey;
|
|
1577
|
+
const version = objectField(resource, "version");
|
|
1578
|
+
if (version.number !== void 0) summary.versionNumber = numberField(version, "number");
|
|
1579
|
+
const when = parseGoRFC3339(stringField(version, "when"));
|
|
1580
|
+
if (when) summary.lastModifiedAt = when.canonical;
|
|
1581
|
+
return summary;
|
|
1582
|
+
}
|
|
1583
|
+
function decodePage(resource, representation, format, maxCharacters) {
|
|
1584
|
+
const id = stringField(resource, "id"), title = stringField(resource, "title"), status = stringField(resource, "status"), spaceId = stringField(resource, "spaceId");
|
|
1585
|
+
if (!idPattern.test(id) || !title || !status || !idPattern.test(spaceId)) throw new TypeError("page identity is invalid");
|
|
1586
|
+
const versionRecord = objectField(resource, "version");
|
|
1587
|
+
const versionNumber = numberField(versionRecord, "number");
|
|
1588
|
+
if (versionNumber < 1) throw new TypeError("page version is invalid");
|
|
1589
|
+
const bodyRecord = objectField(resource, "body");
|
|
1590
|
+
const body = objectField(bodyRecord, representation);
|
|
1591
|
+
const rawBody = stringField(body, "value");
|
|
1592
|
+
const rendered = renderDocumentText(representation === "storage" ? parseStorageDocument(rawBody) : parseADFDocument(rawBody), format, maxCharacters);
|
|
1593
|
+
const page = {
|
|
1594
|
+
id,
|
|
1595
|
+
title,
|
|
1596
|
+
status,
|
|
1597
|
+
spaceId,
|
|
1598
|
+
createdAt: normalizedTime(stringField(resource, "createdAt")),
|
|
1599
|
+
version: { number: versionNumber, createdAt: normalizedTime(stringField(versionRecord, "createdAt")) },
|
|
1600
|
+
body: rendered.text,
|
|
1601
|
+
bodyFormat: format
|
|
1602
|
+
};
|
|
1603
|
+
const parentId = stringField(resource, "parentId");
|
|
1604
|
+
if (idPattern.test(parentId)) page.parentPageId = parentId;
|
|
1605
|
+
const authorId = stringField(resource, "authorId");
|
|
1606
|
+
if (authorId) page.authorAccountId = authorId;
|
|
1607
|
+
const versionAuthorId = stringField(versionRecord, "authorId");
|
|
1608
|
+
if (versionAuthorId) page.version.authorAccountId = versionAuthorId;
|
|
1609
|
+
if (versionRecord.minorEdit === true) page.version.isMinorEdit = true;
|
|
1610
|
+
if (rendered.isTruncated) page.isBodyTruncated = true;
|
|
1611
|
+
const links = objectField(resource, "_links");
|
|
1612
|
+
const url = webURL(stringField(links, "base"), stringField(links, "webui"));
|
|
1613
|
+
if (url) page.webUrl = url;
|
|
1614
|
+
return page;
|
|
1615
|
+
}
|
|
1616
|
+
function normalizedTime(value) {
|
|
1617
|
+
return parseGoRFC3339(value)?.canonical || emptyTime;
|
|
1618
|
+
}
|
|
1619
|
+
function buildCql(filter) {
|
|
1620
|
+
const clauses = ["type = page"];
|
|
1621
|
+
for (const [field, values, valid, description] of [
|
|
1622
|
+
["space", filter.spaceKeys || [], spaceKeyPattern, "a space key such as OPS"],
|
|
1623
|
+
["label", filter.labels || [], /^[^ \t\r\n,]+$/, "a label without whitespace"]
|
|
1624
|
+
]) {
|
|
1625
|
+
if (values.length > 50) throw new TypeError(`filter accepts at most 50 ${field} values`);
|
|
1626
|
+
if (values.length) {
|
|
1627
|
+
const quoted = values.map((value) => {
|
|
1628
|
+
const trimmed = value.trim();
|
|
1629
|
+
if (!valid.test(trimmed) || field === "label" && [...trimmed].length > 255) throw new TypeError(`filter ${field} values must each be ${description}`);
|
|
1630
|
+
return quoteCqlString(trimmed);
|
|
1631
|
+
});
|
|
1632
|
+
clauses.push(`${field} in (${quoted.join(", ")})`);
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
const phrase = (filter.titlePhrase || "").trim();
|
|
1636
|
+
if (phrase) clauses.push("title ~ " + quoteCqlString(quoteCqlString(phrase)));
|
|
1637
|
+
if (filter.modifiedSince) {
|
|
1638
|
+
const timestamp = parseGoRFC3339(filter.modifiedSince);
|
|
1639
|
+
if (!timestamp || filter.modifiedSince.startsWith("0001-01-01T00:00:00")) throw new TypeError("filter modifiedSince must be a time");
|
|
1640
|
+
clauses.push('lastmodified >= "' + new Date(timestamp.epochMs - 12 * 60 * 60 * 1e3).toISOString().slice(0, 10) + '"');
|
|
1641
|
+
}
|
|
1642
|
+
const additional = (filter.additionalCql || "").trim();
|
|
1643
|
+
if (additional) {
|
|
1644
|
+
validateAdditionalCql(additional);
|
|
1645
|
+
clauses.push(`(${additional})`);
|
|
1646
|
+
}
|
|
1647
|
+
const order = filter.order || "lastModifiedDescending";
|
|
1648
|
+
const suffix = order === "lastModifiedDescending" ? "ORDER BY lastmodified DESC" : order === "createdDescending" ? "ORDER BY created DESC" : order === "titleAscending" ? "ORDER BY title ASC" : "";
|
|
1649
|
+
if (!suffix) throw new TypeError("filter order must be lastModifiedDescending, createdDescending, or titleAscending");
|
|
1650
|
+
return clauses.join(" AND ") + " " + suffix;
|
|
1651
|
+
}
|
|
1652
|
+
function quoteCqlString(value) {
|
|
1653
|
+
if ([...value].length > 1024 || hasControlCharacter(value)) throw new TypeError("CQL value cannot contain control characters");
|
|
1654
|
+
return '"' + value.replace(/\\/g, "\\\\").replace(/"/g, '\\"') + '"';
|
|
1655
|
+
}
|
|
1656
|
+
function hasControlCharacter(value) {
|
|
1657
|
+
return [...value].some((character) => {
|
|
1658
|
+
const code = character.codePointAt(0);
|
|
1659
|
+
return code < 32 || code === 127;
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
function validateAdditionalCql(clause) {
|
|
1663
|
+
if ([...clause].length > 4096) throw new TypeError("filter additionalCql cannot exceed 4096 characters");
|
|
1664
|
+
let depth = 0, quote = "", escaped = false, unquoted = "";
|
|
1665
|
+
for (const character of clause) {
|
|
1666
|
+
if (hasControlCharacter(character)) throw new TypeError("filter additionalCql cannot contain control characters");
|
|
1667
|
+
if (escaped) escaped = false;
|
|
1668
|
+
else if (quote && character === "\\") escaped = true;
|
|
1669
|
+
else if (quote && character === quote) quote = "";
|
|
1670
|
+
else if (!quote && (character === '"' || character === "'")) quote = character;
|
|
1671
|
+
else if (!quote && character === "(") depth++;
|
|
1672
|
+
else if (!quote && character === ")") {
|
|
1673
|
+
if (--depth < 0) throw new TypeError("filter additionalCql closes a parenthesis it did not open");
|
|
1674
|
+
}
|
|
1675
|
+
unquoted += quote ? " " : character;
|
|
1676
|
+
}
|
|
1677
|
+
if (quote) throw new TypeError("filter additionalCql has an unterminated string");
|
|
1678
|
+
if (depth) throw new TypeError("filter additionalCql has an unclosed parenthesis");
|
|
1679
|
+
if (/\border\s+by\b/i.test(unquoted)) throw new TypeError("filter additionalCql cannot contain ORDER BY; use order instead");
|
|
1680
|
+
}
|
|
1681
|
+
function emptyResponse() {
|
|
1682
|
+
return { status: 0, headers: {}, body: new Uint8Array(), isTooLarge: false, isDispatched: false };
|
|
1683
|
+
}
|
|
1684
|
+
function validatePageResource(resource) {
|
|
1685
|
+
if (!idPattern.test(stringField(resource, "id"))) throw new TypeError("page ID is not numeric");
|
|
1686
|
+
if (!idPattern.test(stringField(resource, "spaceId"))) throw new TypeError("space ID is not numeric");
|
|
1687
|
+
const title = stringField(resource, "title");
|
|
1688
|
+
if (!title || [...title].length > 1020) throw new TypeError("page title is missing or invalid");
|
|
1689
|
+
if (numberField(objectField(resource, "version"), "number") < 1) throw new TypeError("page version is missing");
|
|
1690
|
+
}
|
|
1691
|
+
function validateTitle(value) {
|
|
1692
|
+
const title = value.trim();
|
|
1693
|
+
if (!title) throw new TypeError("title is required");
|
|
1694
|
+
if ([...title].length > 255) throw new TypeError("title cannot exceed 255 characters");
|
|
1695
|
+
if (hasControlCharacter(title)) throw new TypeError("title must be one line without control characters");
|
|
1696
|
+
return title;
|
|
1697
|
+
}
|
|
1698
|
+
function createdOutput(requested, resource, siteBase, isConfirmed) {
|
|
1699
|
+
const output = { ...requested, pageId: stringField(resource, "id"), spaceId: stringField(resource, "spaceId"), versionNumber: numberField(objectField(resource, "version"), "number") };
|
|
1700
|
+
delete output.parentPageId;
|
|
1701
|
+
const parent = stringField(resource, "parentId");
|
|
1702
|
+
if (idPattern.test(parent)) output.parentPageId = parent;
|
|
1703
|
+
const links = objectField(resource, "_links");
|
|
1704
|
+
const url = webURL(stringField(links, "base") || siteBase, stringField(links, "webui"));
|
|
1705
|
+
if (url) output.webUrl = url;
|
|
1706
|
+
if (isConfirmed) output.isConfirmedByTitleLookup = true;
|
|
1707
|
+
return output;
|
|
1708
|
+
}
|
|
1709
|
+
function updatedOutput(requested, resource, siteBase, isConfirmed) {
|
|
1710
|
+
const output = { ...requested, versionNumber: numberField(objectField(resource, "version"), "number") };
|
|
1711
|
+
const links = objectField(resource, "_links");
|
|
1712
|
+
const url = webURL(stringField(links, "base") || siteBase, stringField(links, "webui"));
|
|
1713
|
+
if (url) output.webUrl = url;
|
|
1714
|
+
if (isConfirmed) output.isConfirmedByReadBack = true;
|
|
1715
|
+
return output;
|
|
1716
|
+
}
|
|
1717
|
+
function addedCommentOutput(requested, comment, isConfirmed) {
|
|
1718
|
+
const output = { ...requested, commentId: stringField(comment, "id") };
|
|
1719
|
+
const timestamp = stringField(objectField(comment, "version"), "createdAt");
|
|
1720
|
+
if (parseGoRFC3339(timestamp)) output.createdAt = normalizedTime(timestamp);
|
|
1721
|
+
if (isConfirmed) output.isConfirmedByReadBack = true;
|
|
1722
|
+
return output;
|
|
1723
|
+
}
|
|
1724
|
+
function storageComparisonText(storage) {
|
|
1725
|
+
try {
|
|
1726
|
+
return documentComparisonText(parseStorageDocument(storage));
|
|
1727
|
+
} catch {
|
|
1728
|
+
return "";
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
function earliestDispatchTime(call, now) {
|
|
1732
|
+
const first = call.context.firstAttemptAt.getTime();
|
|
1733
|
+
return first > 0 ? Math.min(now.getTime(), first) : now.getTime();
|
|
1734
|
+
}
|
|
1735
|
+
function readDispatchCheckpoint(call) {
|
|
1736
|
+
if (!call.context.hasLastHeartbeatValue()) return void 0;
|
|
1737
|
+
try {
|
|
1738
|
+
const value = call.context.getLastHeartbeatValue();
|
|
1739
|
+
if (value && typeof value === "object" && "dispatchedAtUnixMilli" in value && typeof value.dispatchedAtUnixMilli === "number" && value.dispatchedAtUnixMilli > 0) return { dispatchedAt: value.dispatchedAtUnixMilli };
|
|
1740
|
+
} catch {
|
|
1741
|
+
}
|
|
1742
|
+
return { dispatchedAt: 0 };
|
|
1743
|
+
}
|
|
1744
|
+
function clearDispatchCheckpoint(call) {
|
|
1745
|
+
void call.context.recordHeartbeat(void 0).catch(() => {
|
|
1746
|
+
});
|
|
1747
|
+
}
|
|
1748
|
+
async function findPageByTitle(client, session, operation, spaceId, title) {
|
|
1749
|
+
const response = await client.exchange(session, "GET", "content", "/pages", { "space-id": spaceId, title, "body-format": "storage", limit: "5" });
|
|
1750
|
+
let classification = client.classifyRead(operation, "page lookup", response);
|
|
1751
|
+
const lookup = { classification, response, siteBase: "" };
|
|
1752
|
+
if (classification.outcome !== "accepted") return lookup;
|
|
1753
|
+
try {
|
|
1754
|
+
const list = decodeObject(response);
|
|
1755
|
+
const results = list.results;
|
|
1756
|
+
if (!Array.isArray(results) || results.length > 5) throw new TypeError("invalid page list");
|
|
1757
|
+
lookup.siteBase = stringField(objectField(list, "_links"), "base");
|
|
1758
|
+
for (const value of results) {
|
|
1759
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("invalid page");
|
|
1760
|
+
const page = value;
|
|
1761
|
+
validatePageResource(page);
|
|
1762
|
+
if (stringField(page, "title") === title && stringField(page, "spaceId") === spaceId) {
|
|
1763
|
+
lookup.page = page;
|
|
1764
|
+
break;
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
} catch {
|
|
1768
|
+
classification = { outcome: "invalid", failure: confluenceFailure(operation, "PROTOCOL", "Confluence returned an invalid page list"), retryAfterMs: 0 };
|
|
1769
|
+
lookup.classification = classification;
|
|
1770
|
+
}
|
|
1771
|
+
return lookup;
|
|
1772
|
+
}
|
|
1773
|
+
async function readPage(client, session, operation, pageId) {
|
|
1774
|
+
const response = await client.exchange(session, "GET", "content", `/pages/${pathEscape(pageId)}`, { "body-format": "storage" });
|
|
1775
|
+
const lookup = { classification: client.classifyRead(operation, "page", response), response, siteBase: "" };
|
|
1776
|
+
if (lookup.classification.outcome !== "accepted") return lookup;
|
|
1777
|
+
try {
|
|
1778
|
+
const page = decodeObject(response);
|
|
1779
|
+
validatePageResource(page);
|
|
1780
|
+
lookup.page = page;
|
|
1781
|
+
lookup.siteBase = stringField(objectField(page, "_links"), "base");
|
|
1782
|
+
} catch {
|
|
1783
|
+
lookup.classification = { outcome: "invalid", failure: confluenceFailure(operation, "PROTOCOL", "Confluence returned an invalid page"), retryAfterMs: 0 };
|
|
1784
|
+
}
|
|
1785
|
+
return lookup;
|
|
1786
|
+
}
|
|
1787
|
+
async function resolveSpaceId(client, session, operation, spaceKey) {
|
|
1788
|
+
const response = await client.exchange(session, "GET", "content", "/spaces", { keys: spaceKey, limit: "1" });
|
|
1789
|
+
const classification = client.classifyRead(operation, "space", response);
|
|
1790
|
+
if (classification.outcome !== "accepted") return { classification };
|
|
1791
|
+
try {
|
|
1792
|
+
const results = decodeObject(response).results;
|
|
1793
|
+
if (!Array.isArray(results)) throw new TypeError();
|
|
1794
|
+
for (const value of results) {
|
|
1795
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) continue;
|
|
1796
|
+
const resource = value, id = stringField(resource, "id");
|
|
1797
|
+
if (stringField(resource, "key").toLowerCase() === spaceKey.toLowerCase() && idPattern.test(id)) return { spaceId: id };
|
|
1798
|
+
}
|
|
1799
|
+
} catch {
|
|
1800
|
+
return { classification: { outcome: "invalid", failure: confluenceFailure(operation, "PROTOCOL", "Confluence returned an invalid space list"), retryAfterMs: 0 } };
|
|
1801
|
+
}
|
|
1802
|
+
return { classification: { outcome: "notFound", failure: confluenceFailure(operation, "NOT_FOUND", `Confluence space ${spaceKey} was not found or is not visible to the connection`), retryAfterMs: 0 } };
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
// src/client.ts
|
|
1806
|
+
var defaultEndpoint = "https://api.atlassian.com";
|
|
1807
|
+
var cloudIdPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
1808
|
+
var confluenceScopes = /confluence/;
|
|
1809
|
+
var encoder = new TextEncoder();
|
|
1810
|
+
var ConfluenceClient = class {
|
|
1811
|
+
/** Validate connection settings and bind the host credential source. */
|
|
1812
|
+
constructor(config, credentials, options = {}) {
|
|
1813
|
+
this.credentials = credentials;
|
|
1814
|
+
if (!credentials) throw new TypeError("Confluence credential provider is required");
|
|
1815
|
+
this.endpoint = validateBaseURL(config.endpoint || defaultEndpoint);
|
|
1816
|
+
this.configuredCloudId = (config.cloudId || "").trim().toLowerCase();
|
|
1817
|
+
if (this.configuredCloudId && !cloudIdPattern.test(this.configuredCloudId)) throw new TypeError("Confluence cloudId must be a site UUID");
|
|
1818
|
+
this.maxResponseBytes = config.maxResponseBytes || 8388608;
|
|
1819
|
+
if (!Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes < 1) throw new TypeError("Confluence maxResponseBytes must be positive");
|
|
1820
|
+
this.send = options.send ?? sendProviderRequest;
|
|
1821
|
+
this.now = options.now ?? (() => /* @__PURE__ */ new Date());
|
|
1822
|
+
}
|
|
1823
|
+
credentials;
|
|
1824
|
+
endpoint;
|
|
1825
|
+
configuredCloudId;
|
|
1826
|
+
maxResponseBytes;
|
|
1827
|
+
now;
|
|
1828
|
+
send;
|
|
1829
|
+
refreshDriver = new ManifestCredentialRefreshDriver({ providerName: "Atlassian", auth: Authorization, credentialFields: CredentialFields });
|
|
1830
|
+
resolvedCloudId = "";
|
|
1831
|
+
/** Bind the page search Query. */
|
|
1832
|
+
searchPages() {
|
|
1833
|
+
return new SearchPagesOperation(this);
|
|
1834
|
+
}
|
|
1835
|
+
/** Bind the page read Query. */
|
|
1836
|
+
getPage() {
|
|
1837
|
+
return new GetPageOperation(this);
|
|
1838
|
+
}
|
|
1839
|
+
/** Bind the page create Mutation. */
|
|
1840
|
+
createPage() {
|
|
1841
|
+
return new CreatePageOperation(this);
|
|
1842
|
+
}
|
|
1843
|
+
/** Bind the page update Mutation. */
|
|
1844
|
+
updatePage() {
|
|
1845
|
+
return new UpdatePageOperation(this);
|
|
1846
|
+
}
|
|
1847
|
+
/** Bind the footer comment Mutation. */
|
|
1848
|
+
addComment() {
|
|
1849
|
+
return new AddCommentOperation(this);
|
|
1850
|
+
}
|
|
1851
|
+
/** Resolve the OAuth token and the single selected Confluence Cloud site. */
|
|
1852
|
+
async startSession(call, operation) {
|
|
1853
|
+
let credentials;
|
|
1854
|
+
try {
|
|
1855
|
+
credentials = await resolveCredential(this.credentials, call, this.refreshDriver, call.context.cancellationSignal);
|
|
1856
|
+
const token = credentials.accessToken.reveal();
|
|
1857
|
+
if (!isHeaderSafeCredential(token)) throw new TypeError("invalid access token");
|
|
1858
|
+
} catch {
|
|
1859
|
+
return { error: { failure: confluenceFailure(operation, "AUTHENTICATION", "Confluence connection credentials are unavailable; reconnect the connection"), isRetryable: false, retryAfterMs: 0 } };
|
|
1860
|
+
}
|
|
1861
|
+
const session = { call, cloudId: this.configuredCloudId || this.resolvedCloudId, token: credentials.accessToken.reveal() };
|
|
1862
|
+
if (session.cloudId) return { session };
|
|
1863
|
+
const response = await this.exchange(session, "GET", "gateway", "/oauth/token/accessible-resources");
|
|
1864
|
+
if (response.error) return { error: { failure: confluenceFailure(operation, "TRANSPORT", "Atlassian accessible resources are temporarily unavailable"), isRetryable: true, retryAfterMs: 0 } };
|
|
1865
|
+
if (response.status === 429) return { error: { failure: confluenceFailure(operation, "RATE_LIMIT", "Atlassian rate limited the accessible resources lookup"), isRetryable: true, retryAfterMs: this.retryAfter(response) } };
|
|
1866
|
+
if (response.status === 408 || response.status >= 500) return { error: { failure: confluenceFailure(operation, "AVAILABILITY", "Atlassian accessible resources are temporarily unavailable"), isRetryable: true, retryAfterMs: 0 } };
|
|
1867
|
+
if (response.status < 200 || response.status >= 300) return { error: { failure: confluenceFailure(operation, statusFailureKind(response.status), `Atlassian rejected the accessible resources lookup with HTTP ${response.status}; reconnect the connection or set cloudId`), isRetryable: false, retryAfterMs: 0 } };
|
|
1868
|
+
let sites;
|
|
1869
|
+
try {
|
|
1870
|
+
const resources = JSON.parse(new TextDecoder().decode(response.body), (key, value, context) => {
|
|
1871
|
+
if (typeof value === "number" && ["number", "size", "total", "start", "limit"].includes(key) && !/^-?\d+$/.test(context?.source ?? "")) throw new TypeError("invalid Confluence integer");
|
|
1872
|
+
return value;
|
|
1873
|
+
});
|
|
1874
|
+
if (!Array.isArray(resources)) throw new TypeError();
|
|
1875
|
+
sites = [...new Set(resources.filter((resource) => resource && typeof resource === "object" && typeof resource.id === "string" && Array.isArray(resource.scopes) && resource.scopes.some((scope) => typeof scope === "string" && confluenceScopes.test(scope))).map((resource) => resource.id.toLowerCase()).filter((id) => cloudIdPattern.test(id)))].sort();
|
|
1876
|
+
} catch {
|
|
1877
|
+
return { error: { failure: confluenceFailure(operation, "PROTOCOL", "Atlassian returned an invalid accessible resources list; set cloudId"), isRetryable: false, retryAfterMs: 0 } };
|
|
1878
|
+
}
|
|
1879
|
+
if (!sites.length) return { error: { failure: confluenceFailure(operation, "AUTHORIZATION", "the authorization grants no Confluence site; reconnect and pick a Confluence site on the consent screen"), isRetryable: false, retryAfterMs: 0 } };
|
|
1880
|
+
if (sites.length !== 1) return { error: { failure: confluenceFailure(operation, "VALIDATION", `the authorization grants ${sites.length} Confluence sites; choose one with the Confluence site picker or set cloudId`), isRetryable: false, retryAfterMs: 0 } };
|
|
1881
|
+
session.cloudId = sites[0];
|
|
1882
|
+
this.resolvedCloudId = session.cloudId;
|
|
1883
|
+
return { session };
|
|
1884
|
+
}
|
|
1885
|
+
/** Exchange one request and refresh a rejected credential once. */
|
|
1886
|
+
async exchange(session, method, api, path, query, payload) {
|
|
1887
|
+
const prefix = api === "gateway" ? "" : `/ex/confluence/${session.cloudId}/wiki/${api === "content" ? "api/v2" : "rest/api"}`;
|
|
1888
|
+
const search = query ? "?" + encodeGoQuery(query) : "";
|
|
1889
|
+
const url = this.endpoint + prefix + path + search;
|
|
1890
|
+
let body;
|
|
1891
|
+
try {
|
|
1892
|
+
if (payload !== void 0) body = encoder.encode(JSON.stringify(payload));
|
|
1893
|
+
} catch {
|
|
1894
|
+
return { status: 0, headers: {}, body: new Uint8Array(), isTooLarge: false, isDispatched: false, error: "request" };
|
|
1895
|
+
}
|
|
1896
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
1897
|
+
let response;
|
|
1898
|
+
const request = {
|
|
1899
|
+
url,
|
|
1900
|
+
method,
|
|
1901
|
+
headers: { Authorization: `Bearer ${session.token}`, Accept: "application/json", ...body ? { "Content-Type": "application/json" } : {} },
|
|
1902
|
+
...body ? { body } : {},
|
|
1903
|
+
maxResponseBytes: this.maxResponseBytes,
|
|
1904
|
+
timeoutMs: 2e4,
|
|
1905
|
+
addressPolicy: this.endpoint === defaultEndpoint ? "publicHTTPS" : "privateNetworkHTTP",
|
|
1906
|
+
signal: session.call.context.cancellationSignal
|
|
1907
|
+
};
|
|
1908
|
+
try {
|
|
1909
|
+
const received = await this.send(request);
|
|
1910
|
+
response = {
|
|
1911
|
+
...received,
|
|
1912
|
+
isTooLarge: false,
|
|
1913
|
+
isDispatched: true,
|
|
1914
|
+
reflectsSecret: Buffer.from(received.body).includes(Buffer.from(session.token))
|
|
1915
|
+
};
|
|
1916
|
+
} catch (error) {
|
|
1917
|
+
if (error instanceof BodyTooLargeError && error.status !== void 0 && error.headers !== void 0) response = { status: error.status, headers: error.headers, body: new Uint8Array(), isTooLarge: true, isDispatched: true };
|
|
1918
|
+
else return { status: 0, headers: {}, body: new Uint8Array(), isTooLarge: false, isDispatched: !(error instanceof ProviderTransportError && error.isProvablyNotSent), error: "transport" };
|
|
1919
|
+
}
|
|
1920
|
+
if (response.status !== 401 || attempt === 1 || !("resolveAfterRejection" in this.credentials)) return response;
|
|
1921
|
+
try {
|
|
1922
|
+
const replacement = await resolveCredentialAfterRejection(this.credentials, session.call, this.refreshDriver, session.call.context.cancellationSignal);
|
|
1923
|
+
session.token = replacement.accessToken.reveal();
|
|
1924
|
+
if (!isHeaderSafeCredential(session.token)) return response;
|
|
1925
|
+
} catch {
|
|
1926
|
+
return response;
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
throw new Error("Confluence credential rejection retry exhausted");
|
|
1930
|
+
}
|
|
1931
|
+
/** Classify a read without inspecting an error response body. */
|
|
1932
|
+
classifyRead(operation, subject, response) {
|
|
1933
|
+
if (response.error === "request") return classified("defect", confluenceFailure(operation, "LOCAL_DEFECT", "Confluence request could not be built"));
|
|
1934
|
+
if (response.error) return classified("retry", confluenceFailure(operation, "TRANSPORT", `Confluence ${subject} is temporarily unavailable`));
|
|
1935
|
+
if (response.status === 404) return classified("notFound", confluenceFailure(operation, "NOT_FOUND", `Confluence ${subject} was not found or is not visible to the connection`));
|
|
1936
|
+
if (response.status === 429) return classified("retry", confluenceFailure(operation, "RATE_LIMIT", `Confluence rate limited the ${subject}`), this.retryAfter(response));
|
|
1937
|
+
if (response.status === 408 || response.status >= 500) return classified("retry", confluenceFailure(operation, "AVAILABILITY", `Confluence ${subject} is temporarily unavailable`), this.retryAfter(response));
|
|
1938
|
+
if (response.status >= 400 && response.status < 500) return classified("rejected", confluenceFailure(operation, statusFailureKind(response.status), `Confluence rejected the ${subject} with HTTP ${response.status}`));
|
|
1939
|
+
if (response.status < 200 || response.status >= 300) return classified("invalid", confluenceFailure(operation, "PROTOCOL", `Confluence returned unexpected HTTP ${response.status} for the ${subject}`));
|
|
1940
|
+
if (response.isTooLarge) return classified("invalid", confluenceFailure(operation, "RESPONSE_TOO_LARGE", `Confluence ${subject} response exceeds the configured size limit`));
|
|
1941
|
+
if (response.reflectsSecret) return classified("invalid", confluenceFailure(operation, "PROTOCOL", `Confluence ${subject} response contains credential material`));
|
|
1942
|
+
return classified("accepted");
|
|
1943
|
+
}
|
|
1944
|
+
/** Classify a write before any read-back or business reconciliation. */
|
|
1945
|
+
classifyWrite(operation, subject, response) {
|
|
1946
|
+
if (response.error === "request") return classified("defect", confluenceFailure(operation, "LOCAL_DEFECT", "Confluence request could not be built"));
|
|
1947
|
+
if (response.error && !response.isDispatched) return classified("notApplied", confluenceFailure(operation, "TRANSPORT", `Confluence could not be reached, so no ${subject} was written`));
|
|
1948
|
+
if (response.error) return classified("ambiguous", confluenceFailure(operation, "TRANSPORT", `Confluence ${subject} outcome is unknown`));
|
|
1949
|
+
if (response.status >= 200 && response.status < 300) {
|
|
1950
|
+
if (response.isTooLarge) return classified("ambiguous", confluenceFailure(operation, "RESPONSE_TOO_LARGE", `Confluence accepted the ${subject} but its response exceeds the configured size limit`));
|
|
1951
|
+
if (response.reflectsSecret) return classified("ambiguous", confluenceFailure(operation, "PROTOCOL", `Confluence accepted the ${subject} but its response contains credential material`));
|
|
1952
|
+
return classified("accepted");
|
|
1953
|
+
}
|
|
1954
|
+
if (response.status === 429) return classified("notApplied", confluenceFailure(operation, "RATE_LIMIT", `Confluence rate limited the ${subject} before writing it`), this.retryAfter(response));
|
|
1955
|
+
if (response.status === 404) return classified("notFound", confluenceFailure(operation, "NOT_FOUND", `Confluence rejected the ${subject} with HTTP 404`));
|
|
1956
|
+
if (response.status >= 400 && response.status < 500 && response.status !== 408) return classified("rejected", confluenceFailure(operation, statusFailureKind(response.status), `Confluence rejected the ${subject} with HTTP ${response.status}`));
|
|
1957
|
+
return classified("ambiguous", confluenceFailure(operation, "AVAILABILITY", `Confluence ${subject} outcome is unknown after HTTP ${response.status}`), this.retryAfter(response));
|
|
1958
|
+
}
|
|
1959
|
+
/** Produce a safe request receipt with the exact provider object identifier. */
|
|
1960
|
+
receipt(session, response, objectId = "") {
|
|
1961
|
+
const traceId = response.headers["atl-traceid"];
|
|
1962
|
+
const safeTrace = typeof traceId === "string" && /^[\x21-\x7e]{1,128}$/.test(traceId) ? traceId : "";
|
|
1963
|
+
return {
|
|
1964
|
+
callId: session.call.id,
|
|
1965
|
+
provider: "confluence",
|
|
1966
|
+
observedAt: this.now().toISOString(),
|
|
1967
|
+
...session.call.idempotencyKey ? { idempotencyKey: session.call.idempotencyKey } : {},
|
|
1968
|
+
...objectId ? { providerObjectId: objectId } : {},
|
|
1969
|
+
...safeTrace ? { providerRequestId: safeTrace } : {}
|
|
1970
|
+
};
|
|
1971
|
+
}
|
|
1972
|
+
/** Parse Retry-After against the injected clock. */
|
|
1973
|
+
retryAfter(response) {
|
|
1974
|
+
const header = response.headers["retry-after"];
|
|
1975
|
+
return parseRetryAfter(typeof header === "string" ? header : "", this.now());
|
|
1976
|
+
}
|
|
1977
|
+
};
|
|
1978
|
+
function classified(outcome, failure, retryAfterMs = 0) {
|
|
1979
|
+
return { outcome, ...failure ? { failure } : {}, retryAfterMs };
|
|
1980
|
+
}
|
|
1981
|
+
function confluenceFailure(operation, kind, message) {
|
|
1982
|
+
return { provider: "confluence", operation, kind, message };
|
|
1983
|
+
}
|
|
1984
|
+
function statusFailureKind(status) {
|
|
1985
|
+
return status === 400 ? "VALIDATION" : status === 401 ? "AUTHENTICATION" : status === 403 ? "AUTHORIZATION" : status === 404 ? "NOT_FOUND" : status === 409 ? "CONFLICT" : status === 429 ? "RATE_LIMIT" : "PROVIDER_REJECTION";
|
|
1986
|
+
}
|
|
1987
|
+
function queryEscape(value) {
|
|
1988
|
+
return encodeURIComponent(value).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%20/g, "+");
|
|
1989
|
+
}
|
|
1990
|
+
function decodeObject(response) {
|
|
1991
|
+
const decoded = JSON.parse(new TextDecoder().decode(response.body), (key, value, context) => {
|
|
1992
|
+
if (typeof value === "number" && ["number", "size", "total", "start", "limit"].includes(key) && !/^-?\d+$/.test(context?.source ?? "")) throw new TypeError("invalid Confluence integer");
|
|
1993
|
+
return value;
|
|
1994
|
+
});
|
|
1995
|
+
if (!decoded || typeof decoded !== "object" || Array.isArray(decoded)) throw new TypeError("invalid response object");
|
|
1996
|
+
return decoded;
|
|
1997
|
+
}
|
|
1998
|
+
function pathEscape(value) {
|
|
1999
|
+
return encodeURIComponent(value).replace(/[!'()*]/g, (character) => "%" + character.charCodeAt(0).toString(16).toUpperCase()).replace(/%24/g, "$").replace(/%26/g, "&").replace(/%2B/g, "+").replace(/%3D/g, "=").replace(/%3A/g, ":").replace(/%40/g, "@");
|
|
2000
|
+
}
|
|
2001
|
+
function encodeGoQuery(values) {
|
|
2002
|
+
return Object.keys(values).sort((left, right) => Buffer.compare(Buffer.from(left), Buffer.from(right))).flatMap((key) => (Array.isArray(values[key]) ? values[key] : [values[key]]).map((value) => `${queryEscape(key)}=${queryEscape(value)}`)).join("&");
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
// src/project.ts
|
|
2006
|
+
function encodeCredentials(credentials) {
|
|
2007
|
+
return {
|
|
2008
|
+
oauth_client_id: credentials.oauthClientId,
|
|
2009
|
+
oauth_client_secret: credentials.oauthClientSecret.reveal(),
|
|
2010
|
+
access_token: credentials.accessToken.reveal(),
|
|
2011
|
+
refresh_token: credentials.refreshToken.reveal()
|
|
2012
|
+
};
|
|
2013
|
+
}
|
|
2014
|
+
function newProjectConnection2(project, connectionName, options = {}) {
|
|
2015
|
+
return newProjectConnection(project, connectionName, (loadedProject, name) => {
|
|
2016
|
+
const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "confluence" && entry.connectionName === name);
|
|
2017
|
+
if (!selected) throw new TypeError("Confluence project connection is not configured");
|
|
2018
|
+
const settings = ConfigSchema.parse(selected.configuration);
|
|
2019
|
+
const config = {
|
|
2020
|
+
...settings.cloudId !== void 0 ? { cloudId: settings.cloudId } : {},
|
|
2021
|
+
...settings.endpoint !== void 0 ? { endpoint: settings.endpoint } : {},
|
|
2022
|
+
...settings.maxResponseBytes !== void 0 ? { maxResponseBytes: settings.maxResponseBytes } : {}
|
|
2023
|
+
};
|
|
2024
|
+
return new ConfluenceClient(config, newProjectCredentialProvider(loadedProject, name, decodeCredentials, encodeCredentials, decodeSharedCredentials), options);
|
|
2025
|
+
});
|
|
2026
|
+
}
|
|
2027
|
+
export {
|
|
2028
|
+
AddCommentBranch,
|
|
2029
|
+
AddCommentBranchAdded,
|
|
2030
|
+
AddCommentBranchDefect,
|
|
2031
|
+
AddCommentBranchNotFound,
|
|
2032
|
+
AddCommentBranchProviderRejected,
|
|
2033
|
+
AddCommentBranchUncertain,
|
|
2034
|
+
AddCommentDefinition,
|
|
2035
|
+
AddCommentInputSchema,
|
|
2036
|
+
AddCommentMetadata,
|
|
2037
|
+
AddCommentOperation,
|
|
2038
|
+
AddCommentOutputSchema,
|
|
2039
|
+
ConfigSchema,
|
|
2040
|
+
ConfluenceClient,
|
|
2041
|
+
Connection,
|
|
2042
|
+
ConnectorID,
|
|
2043
|
+
CreatePageBranch,
|
|
2044
|
+
CreatePageBranchCreated,
|
|
2045
|
+
CreatePageBranchDefect,
|
|
2046
|
+
CreatePageBranchNotFound,
|
|
2047
|
+
CreatePageBranchProviderRejected,
|
|
2048
|
+
CreatePageBranchTitleConflict,
|
|
2049
|
+
CreatePageDefinition,
|
|
2050
|
+
CreatePageInputSchema,
|
|
2051
|
+
CreatePageMetadata,
|
|
2052
|
+
CreatePageOperation,
|
|
2053
|
+
CreatePageOutputSchema,
|
|
2054
|
+
GetPageBranch,
|
|
2055
|
+
GetPageBranchDefect,
|
|
2056
|
+
GetPageBranchFound,
|
|
2057
|
+
GetPageBranchInvalidResponse,
|
|
2058
|
+
GetPageBranchNotFound,
|
|
2059
|
+
GetPageBranchProviderRejected,
|
|
2060
|
+
GetPageDefinition,
|
|
2061
|
+
GetPageInputSchema,
|
|
2062
|
+
GetPageMetadata,
|
|
2063
|
+
GetPageOperation,
|
|
2064
|
+
PageSchema,
|
|
2065
|
+
PageSearchFilterSchema,
|
|
2066
|
+
PageSummarySchema,
|
|
2067
|
+
PageVersionSchema,
|
|
2068
|
+
ProviderID,
|
|
2069
|
+
SearchPagesBranch,
|
|
2070
|
+
SearchPagesBranchDefect,
|
|
2071
|
+
SearchPagesBranchInvalidResponse,
|
|
2072
|
+
SearchPagesBranchProviderRejected,
|
|
2073
|
+
SearchPagesBranchSearched,
|
|
2074
|
+
SearchPagesDefinition,
|
|
2075
|
+
SearchPagesInputSchema,
|
|
2076
|
+
SearchPagesMetadata,
|
|
2077
|
+
SearchPagesOperation,
|
|
2078
|
+
SearchPagesOutputSchema,
|
|
2079
|
+
UpdatePageBranch,
|
|
2080
|
+
UpdatePageBranchDefect,
|
|
2081
|
+
UpdatePageBranchNotFound,
|
|
2082
|
+
UpdatePageBranchProviderRejected,
|
|
2083
|
+
UpdatePageBranchUpdated,
|
|
2084
|
+
UpdatePageBranchVersionConflict,
|
|
2085
|
+
UpdatePageDefinition,
|
|
2086
|
+
UpdatePageInputSchema,
|
|
2087
|
+
UpdatePageMetadata,
|
|
2088
|
+
UpdatePageOperation,
|
|
2089
|
+
UpdatePageOutputSchema,
|
|
2090
|
+
decodeCredentials,
|
|
2091
|
+
decodeSharedCredentials,
|
|
2092
|
+
newAddCommentStep,
|
|
2093
|
+
newConnection,
|
|
2094
|
+
newConnectionWithOperations,
|
|
2095
|
+
newCreatePageStep,
|
|
2096
|
+
newGetPageStep,
|
|
2097
|
+
newProjectConnection2 as newProjectConnection,
|
|
2098
|
+
newSearchPagesStep,
|
|
2099
|
+
newUpdatePageStep
|
|
2100
|
+
};
|