Skip to content

Commit f027677

Browse files
author
Allen Manning
authored
Merge pull request #3993 from quarto-dev/feature/site-nesting
Feature/site nesting
2 parents 2083b1d + fba6603 commit f027677

File tree

6 files changed

+2398
-467
lines changed

6 files changed

+2398
-467
lines changed

src/publish/confluence/api/index.ts

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
WrappedResult,
2626
} from "./types.ts";
2727

28-
import { DESCENDANT_LIMIT } from "../constants.ts";
28+
import { DESCENDANT_LIMIT, V2EDITOR_METADATA } from "../constants.ts";
2929
import { logError, trace } from "../confluence-logger.ts";
3030

3131
export class ConfluenceClient {
@@ -53,14 +53,23 @@ export class ConfluenceClient {
5353

5454
public getDescendants(
5555
id: string,
56-
expand = ["metadata.properties"]
56+
expand = ["metadata.properties", "ancestors"]
5757
): Promise<WrappedResult<ContentSummary>> {
5858
const url = `content/${id}/descendant/page?limit=${DESCENDANT_LIMIT}&expand=${expand}`;
5959
return this.get<WrappedResult<ContentSummary>>(url);
6060
}
6161

62-
public async isTitleInSpace(title: string, space: Space): Promise<boolean> {
62+
public async isTitleInSpace(
63+
title: string,
64+
space: Space,
65+
idToIgnore: string = ""
66+
): Promise<boolean> {
6367
const result = await this.fetchMatchingTitlePages(title, space);
68+
69+
if (result.length === 1 && result[0].id === idToIgnore) {
70+
return false;
71+
}
72+
6473
return result.length > 0;
6574
}
6675

@@ -75,24 +84,42 @@ export class ConfluenceClient {
7584
return result?.results ?? [];
7685
}
7786

78-
public createContent(content: ContentCreate): Promise<Content> {
87+
public createContent(
88+
content: ContentCreate,
89+
metadata: Record<string, any> = V2EDITOR_METADATA
90+
): Promise<Content> {
91+
const toCreate = {
92+
...content,
93+
...metadata,
94+
};
95+
96+
trace("to create", toCreate);
7997
trace("createContent body", content.body.storage.value);
80-
const createBody = JSON.stringify(content);
98+
const createBody = JSON.stringify(toCreate);
8199
return this.post<Content>("content", createBody);
82100
}
83101

102+
public updateContent(
103+
content: ContentUpdate,
104+
metadata: Record<string, any> = V2EDITOR_METADATA
105+
): Promise<Content> {
106+
const toUpdate = {
107+
...content,
108+
...metadata,
109+
};
110+
trace("updateContent", toUpdate);
111+
return this.put<Content>(`content/${content.id}`, JSON.stringify(toUpdate));
112+
}
113+
84114
public createContentProperty(id: string, content: any): Promise<Content> {
85115
return this.post<Content>(
86116
`content/${id}/property`,
87117
JSON.stringify(content)
88118
);
89119
}
90120

91-
public updateContent(content: ContentUpdate): Promise<Content> {
92-
return this.put<Content>(`content/${content.id}`, JSON.stringify(content));
93-
}
94-
95121
public deleteContent(content: ContentDelete): Promise<Content> {
122+
trace("deleteContent", content);
96123
return this.delete<Content>(`content/${content.id}`);
97124
}
98125

src/publish/confluence/api/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,15 @@ export type SiteFileMetadata = {
191191

192192
export type ContentSummary = {
193193
id: string | null;
194+
ancestors?: ContentAncestor[] | null;
194195
title: string | null;
195196
};
196197

197198
export type SitePage = {
198199
id: string;
199200
metadata: Record<string, any>;
200201
title: string | null;
202+
ancestors?: ContentAncestor[] | null;
201203
};
202204

203205
export type ExtractedLink = {

0 commit comments

Comments
 (0)