@hesed/conni 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -22
- package/dist/commands/conni/auth/add.d.ts +2 -15
- package/dist/commands/conni/auth/add.js +7 -60
- package/dist/commands/conni/auth/delete.d.ts +2 -0
- package/dist/commands/conni/auth/delete.js +2 -0
- package/dist/commands/conni/auth/list.d.ts +2 -20
- package/dist/commands/conni/auth/list.js +2 -36
- package/dist/commands/conni/auth/profile.d.ts +2 -11
- package/dist/commands/conni/auth/profile.js +2 -23
- package/dist/commands/conni/auth/test.d.ts +2 -12
- package/dist/commands/conni/auth/test.js +7 -37
- package/dist/commands/conni/auth/update.d.ts +2 -15
- package/dist/commands/conni/auth/update.js +7 -83
- package/dist/commands/conni/content/attachment-download.js +5 -5
- package/dist/commands/conni/content/attachment.js +5 -5
- package/dist/commands/conni/content/comment-delete.js +5 -5
- package/dist/commands/conni/content/comment-update.js +5 -5
- package/dist/commands/conni/content/comment.js +5 -5
- package/dist/commands/conni/content/create.js +5 -7
- package/dist/commands/conni/content/delete.js +5 -5
- package/dist/commands/conni/content/get.js +5 -5
- package/dist/commands/conni/content/search.js +5 -5
- package/dist/commands/conni/content/update.js +5 -5
- package/dist/commands/conni/space/get.js +5 -5
- package/dist/commands/conni/space/list.js +5 -5
- package/dist/conni/conni-api.d.ts +2 -14
- package/dist/conni/conni-client.d.ts +17 -95
- package/dist/conni/conni-client.js +17 -115
- package/oclif.manifest.json +139 -94
- package/package.json +2 -2
- package/dist/config.d.ts +0 -14
- package/dist/config.js +0 -83
- package/dist/format.d.ts +0 -4
- package/dist/format.js +0 -10
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { createProfileManager, formatAsToon } from '@hesed/plugin-lib';
|
|
1
2
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
|
-
import { readConfig } from '../../../config.js';
|
|
3
3
|
import { clearClients, deleteComment } from '../../../conni/conni-client.js';
|
|
4
|
-
import { formatAsToon } from '../../../format.js';
|
|
5
4
|
export default class ContentDeleteComment extends Command {
|
|
6
5
|
static args = {
|
|
7
6
|
id: Args.string({ description: 'Comment ID to delete', required: true }),
|
|
@@ -14,11 +13,12 @@ export default class ContentDeleteComment extends Command {
|
|
|
14
13
|
};
|
|
15
14
|
async run() {
|
|
16
15
|
const { args, flags } = await this.parse(ContentDeleteComment);
|
|
17
|
-
const
|
|
18
|
-
|
|
16
|
+
const { loadAuthConfig } = createProfileManager(this.config, flags.profile);
|
|
17
|
+
const auth = await loadAuthConfig();
|
|
18
|
+
if (!auth) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
const result = await deleteComment(
|
|
21
|
+
const result = await deleteComment(auth, args.id);
|
|
22
22
|
clearClients();
|
|
23
23
|
if (flags.toon) {
|
|
24
24
|
this.log(formatAsToon(result));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { createProfileManager, formatAsToon } from '@hesed/plugin-lib';
|
|
1
2
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
|
-
import { readConfig } from '../../../config.js';
|
|
3
3
|
import { clearClients, updateComment } from '../../../conni/conni-client.js';
|
|
4
|
-
import { formatAsToon } from '../../../format.js';
|
|
5
4
|
export default class ContentUpdateComment extends Command {
|
|
6
5
|
/* eslint-disable perfectionist/sort-objects */
|
|
7
6
|
static args = {
|
|
@@ -20,11 +19,12 @@ export default class ContentUpdateComment extends Command {
|
|
|
20
19
|
};
|
|
21
20
|
async run() {
|
|
22
21
|
const { args, flags } = await this.parse(ContentUpdateComment);
|
|
23
|
-
const
|
|
24
|
-
|
|
22
|
+
const { loadAuthConfig } = createProfileManager(this.config, flags.profile);
|
|
23
|
+
const auth = await loadAuthConfig();
|
|
24
|
+
if (!auth) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
const result = await updateComment(
|
|
27
|
+
const result = await updateComment(auth, args.id, args.body);
|
|
28
28
|
clearClients();
|
|
29
29
|
if (flags.toon) {
|
|
30
30
|
this.log(formatAsToon(result));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { createProfileManager, formatAsToon } from '@hesed/plugin-lib';
|
|
1
2
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
|
-
import { readConfig } from '../../../config.js';
|
|
3
3
|
import { addComment, clearClients } from '../../../conni/conni-client.js';
|
|
4
|
-
import { formatAsToon } from '../../../format.js';
|
|
5
4
|
export default class ContentAddComment extends Command {
|
|
6
5
|
/* eslint-disable perfectionist/sort-objects */
|
|
7
6
|
static args = {
|
|
@@ -20,11 +19,12 @@ export default class ContentAddComment extends Command {
|
|
|
20
19
|
};
|
|
21
20
|
async run() {
|
|
22
21
|
const { args, flags } = await this.parse(ContentAddComment);
|
|
23
|
-
const
|
|
24
|
-
|
|
22
|
+
const { loadAuthConfig } = createProfileManager(this.config, flags.profile);
|
|
23
|
+
const auth = await loadAuthConfig();
|
|
24
|
+
if (!auth) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
const result = await addComment(
|
|
27
|
+
const result = await addComment(auth, args.pageId, args.body);
|
|
28
28
|
clearClients();
|
|
29
29
|
if (flags.toon) {
|
|
30
30
|
this.log(formatAsToon(result));
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { createProfileManager, formatAsToon } from '@hesed/plugin-lib';
|
|
1
2
|
import { Command, Flags } from '@oclif/core';
|
|
2
3
|
import fs from 'fs-extra';
|
|
3
|
-
import { readConfig } from '../../../config.js';
|
|
4
4
|
import { clearClients, createPage, createPageWithMedia } from '../../../conni/conni-client.js';
|
|
5
|
-
import { formatAsToon } from '../../../format.js';
|
|
6
5
|
export default class ContentCreate extends Command {
|
|
7
6
|
static args = {};
|
|
8
7
|
static description = 'Create a new Confluence page';
|
|
@@ -35,8 +34,9 @@ export default class ContentCreate extends Command {
|
|
|
35
34
|
};
|
|
36
35
|
async run() {
|
|
37
36
|
const { flags } = await this.parse(ContentCreate);
|
|
38
|
-
const
|
|
39
|
-
|
|
37
|
+
const { loadAuthConfig } = createProfileManager(this.config, flags.profile);
|
|
38
|
+
const auth = await loadAuthConfig();
|
|
39
|
+
if (!auth) {
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
const fields = {};
|
|
@@ -61,9 +61,7 @@ export default class ContentCreate extends Command {
|
|
|
61
61
|
if (flags['full-width']) {
|
|
62
62
|
fields.fullWidth = 'true';
|
|
63
63
|
}
|
|
64
|
-
const result = flags.attach
|
|
65
|
-
? await createPageWithMedia(config.auth, fields, flags.attach)
|
|
66
|
-
: await createPage(config.auth, fields);
|
|
64
|
+
const result = flags.attach ? await createPageWithMedia(auth, fields, flags.attach) : await createPage(auth, fields);
|
|
67
65
|
clearClients();
|
|
68
66
|
if (flags.toon) {
|
|
69
67
|
this.log(formatAsToon(result));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { createProfileManager, formatAsToon } from '@hesed/plugin-lib';
|
|
1
2
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
|
-
import { readConfig } from '../../../config.js';
|
|
3
3
|
import { clearClients, deleteContent } from '../../../conni/conni-client.js';
|
|
4
|
-
import { formatAsToon } from '../../../format.js';
|
|
5
4
|
export default class ContentDelete extends Command {
|
|
6
5
|
static args = {
|
|
7
6
|
pageId: Args.string({ description: 'Page ID to delete', required: true }),
|
|
@@ -14,11 +13,12 @@ export default class ContentDelete extends Command {
|
|
|
14
13
|
};
|
|
15
14
|
async run() {
|
|
16
15
|
const { args, flags } = await this.parse(ContentDelete);
|
|
17
|
-
const
|
|
18
|
-
|
|
16
|
+
const { loadAuthConfig } = createProfileManager(this.config, flags.profile);
|
|
17
|
+
const auth = await loadAuthConfig();
|
|
18
|
+
if (!auth) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
const result = await deleteContent(
|
|
21
|
+
const result = await deleteContent(auth, args.pageId);
|
|
22
22
|
clearClients();
|
|
23
23
|
if (flags.toon) {
|
|
24
24
|
this.log(formatAsToon(result));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { createProfileManager, formatAsToon } from '@hesed/plugin-lib';
|
|
1
2
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
|
-
import { readConfig } from '../../../config.js';
|
|
3
3
|
import { clearClients, getContent } from '../../../conni/conni-client.js';
|
|
4
|
-
import { formatAsToon } from '../../../format.js';
|
|
5
4
|
export default class ContentGet extends Command {
|
|
6
5
|
static args = {
|
|
7
6
|
pageId: Args.string({ description: 'Page ID', required: true }),
|
|
@@ -14,11 +13,12 @@ export default class ContentGet extends Command {
|
|
|
14
13
|
};
|
|
15
14
|
async run() {
|
|
16
15
|
const { args, flags } = await this.parse(ContentGet);
|
|
17
|
-
const
|
|
18
|
-
|
|
16
|
+
const { loadAuthConfig } = createProfileManager(this.config, flags.profile);
|
|
17
|
+
const auth = await loadAuthConfig();
|
|
18
|
+
if (!auth) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
const result = await getContent(
|
|
21
|
+
const result = await getContent(auth, args.pageId);
|
|
22
22
|
clearClients();
|
|
23
23
|
if (flags.toon) {
|
|
24
24
|
this.log(formatAsToon(result));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { createProfileManager, formatAsToon } from '@hesed/plugin-lib';
|
|
1
2
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
|
-
import { readConfig } from '../../../config.js';
|
|
3
3
|
import { clearClients, searchContents } from '../../../conni/conni-client.js';
|
|
4
|
-
import { formatAsToon } from '../../../format.js';
|
|
5
4
|
export default class ContentSearch extends Command {
|
|
6
5
|
static args = {
|
|
7
6
|
cql: Args.string({ description: 'CQL expression', required: true }),
|
|
@@ -19,11 +18,12 @@ export default class ContentSearch extends Command {
|
|
|
19
18
|
};
|
|
20
19
|
async run() {
|
|
21
20
|
const { args, flags } = await this.parse(ContentSearch);
|
|
22
|
-
const
|
|
23
|
-
|
|
21
|
+
const { loadAuthConfig } = createProfileManager(this.config, flags.profile);
|
|
22
|
+
const auth = await loadAuthConfig();
|
|
23
|
+
if (!auth) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
const result = await searchContents(
|
|
26
|
+
const result = await searchContents(auth, args.cql, flags.limit, flags.expand ? flags.expand.split(',') : undefined);
|
|
27
27
|
clearClients();
|
|
28
28
|
if (flags.toon) {
|
|
29
29
|
this.log(formatAsToon(result));
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { createProfileManager, formatAsToon } from '@hesed/plugin-lib';
|
|
1
2
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
3
|
import fs from 'fs-extra';
|
|
3
|
-
import { readConfig } from '../../../config.js';
|
|
4
4
|
import { clearClients, updateContent } from '../../../conni/conni-client.js';
|
|
5
|
-
import { formatAsToon } from '../../../format.js';
|
|
6
5
|
export default class ContentUpdate extends Command {
|
|
7
6
|
static args = {
|
|
8
7
|
pageId: Args.string({ description: 'Page ID', required: true }),
|
|
@@ -29,8 +28,9 @@ export default class ContentUpdate extends Command {
|
|
|
29
28
|
};
|
|
30
29
|
async run() {
|
|
31
30
|
const { args, flags } = await this.parse(ContentUpdate);
|
|
32
|
-
const
|
|
33
|
-
|
|
31
|
+
const { loadAuthConfig } = createProfileManager(this.config, flags.profile);
|
|
32
|
+
const auth = await loadAuthConfig();
|
|
33
|
+
if (!auth) {
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
const fields = {};
|
|
@@ -48,7 +48,7 @@ export default class ContentUpdate extends Command {
|
|
|
48
48
|
if (flags['full-width']) {
|
|
49
49
|
fields.fullWidth = 'true';
|
|
50
50
|
}
|
|
51
|
-
const result = await updateContent(
|
|
51
|
+
const result = await updateContent(auth, args.pageId, fields);
|
|
52
52
|
clearClients();
|
|
53
53
|
if (flags.toon) {
|
|
54
54
|
this.log(formatAsToon(result));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { createProfileManager, formatAsToon } from '@hesed/plugin-lib';
|
|
1
2
|
import { Args, Command, Flags } from '@oclif/core';
|
|
2
|
-
import { readConfig } from '../../../config.js';
|
|
3
3
|
import { clearClients, getSpace } from '../../../conni/conni-client.js';
|
|
4
|
-
import { formatAsToon } from '../../../format.js';
|
|
5
4
|
export default class SpaceGet extends Command {
|
|
6
5
|
static args = {
|
|
7
6
|
spaceKey: Args.string({ description: 'Space key', required: true }),
|
|
@@ -14,11 +13,12 @@ export default class SpaceGet extends Command {
|
|
|
14
13
|
};
|
|
15
14
|
async run() {
|
|
16
15
|
const { args, flags } = await this.parse(SpaceGet);
|
|
17
|
-
const
|
|
18
|
-
|
|
16
|
+
const { loadAuthConfig } = createProfileManager(this.config, flags.profile);
|
|
17
|
+
const auth = await loadAuthConfig();
|
|
18
|
+
if (!auth) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
const result = await getSpace(
|
|
21
|
+
const result = await getSpace(auth, args.spaceKey);
|
|
22
22
|
clearClients();
|
|
23
23
|
if (flags.toon) {
|
|
24
24
|
this.log(formatAsToon(result));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { createProfileManager, formatAsToon } from '@hesed/plugin-lib';
|
|
1
2
|
import { Command, Flags } from '@oclif/core';
|
|
2
|
-
import { readConfig } from '../../../config.js';
|
|
3
3
|
import { clearClients, listSpaces } from '../../../conni/conni-client.js';
|
|
4
|
-
import { formatAsToon } from '../../../format.js';
|
|
5
4
|
export default class SpaceList extends Command {
|
|
6
5
|
static description = 'List all Confluence spaces';
|
|
7
6
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
@@ -11,11 +10,12 @@ export default class SpaceList extends Command {
|
|
|
11
10
|
};
|
|
12
11
|
async run() {
|
|
13
12
|
const { flags } = await this.parse(SpaceList);
|
|
14
|
-
const
|
|
15
|
-
|
|
13
|
+
const { loadAuthConfig } = createProfileManager(this.config, flags.profile);
|
|
14
|
+
const auth = await loadAuthConfig();
|
|
15
|
+
if (!auth) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
const result = await listSpaces(
|
|
18
|
+
const result = await listSpaces(auth);
|
|
19
19
|
clearClients();
|
|
20
20
|
if (flags.toon) {
|
|
21
21
|
this.log(formatAsToon(result));
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import { ConfluenceClient } from 'confluence.js';
|
|
2
|
-
|
|
3
|
-
* Generic API result
|
|
4
|
-
*/
|
|
5
|
-
export interface ApiResult {
|
|
6
|
-
data?: unknown;
|
|
7
|
-
error?: unknown;
|
|
8
|
-
success: boolean;
|
|
9
|
-
}
|
|
10
|
-
export interface Config {
|
|
11
|
-
apiToken: string;
|
|
12
|
-
email?: string;
|
|
13
|
-
host: string;
|
|
14
|
-
}
|
|
2
|
+
import { type ApiResult, type AuthConfig } from '@hesed/plugin-lib';
|
|
15
3
|
/**
|
|
16
4
|
* Confluence API Utility
|
|
17
5
|
* Provides core Confluence API operations
|
|
@@ -19,7 +7,7 @@ export interface Config {
|
|
|
19
7
|
export declare class ConniApi {
|
|
20
8
|
private client?;
|
|
21
9
|
private config;
|
|
22
|
-
constructor(config:
|
|
10
|
+
constructor(config: AuthConfig);
|
|
23
11
|
/**
|
|
24
12
|
* Add an attachment to a page
|
|
25
13
|
*/
|
|
@@ -1,95 +1,17 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export declare function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* @param expand - Properties of the content to expand
|
|
19
|
-
*/
|
|
20
|
-
export declare function searchContents(config: Config, cql: string, limit?: number, expand?: string[]): Promise<ApiResult>;
|
|
21
|
-
/**
|
|
22
|
-
* Get page details
|
|
23
|
-
* @param config - Confluence configuration
|
|
24
|
-
* @param pageId - Page ID
|
|
25
|
-
*/
|
|
26
|
-
export declare function getContent(config: Config, pageId: string): Promise<ApiResult>;
|
|
27
|
-
/**
|
|
28
|
-
* Create a new page
|
|
29
|
-
* @param config - Confluence configuration
|
|
30
|
-
* @param fields - Page fields (spaceKey, title, body, parentId)
|
|
31
|
-
*/
|
|
32
|
-
export declare function createPage(config: Config, fields: Record<string, unknown>): Promise<ApiResult>;
|
|
33
|
-
/**
|
|
34
|
-
* Create a new page with inline media attachments
|
|
35
|
-
* @param config - Confluence configuration
|
|
36
|
-
* @param fields - Page fields (spaceKey, title, body, parentId)
|
|
37
|
-
* @param filePaths - Local file paths to upload and embed inline
|
|
38
|
-
*/
|
|
39
|
-
export declare function createPageWithMedia(config: Config, fields: Record<string, unknown>, filePaths: string[]): Promise<ApiResult>;
|
|
40
|
-
/**
|
|
41
|
-
* Update an existing page
|
|
42
|
-
* @param config - Confluence configuration
|
|
43
|
-
* @param pageId - Page ID
|
|
44
|
-
* @param fields - Page fields to update (title, body)
|
|
45
|
-
*/
|
|
46
|
-
export declare function updateContent(config: Config, pageId: string, fields: Record<string, unknown>): Promise<ApiResult>;
|
|
47
|
-
/**
|
|
48
|
-
* Add an attachment to a page
|
|
49
|
-
* @param config - Confluence configuration
|
|
50
|
-
* @param pageId - Page ID
|
|
51
|
-
* @param filePath - Path to the file to upload
|
|
52
|
-
*/
|
|
53
|
-
export declare function addAttachment(config: Config, pageId: string, filePath: string): Promise<ApiResult>;
|
|
54
|
-
/**
|
|
55
|
-
* Add a comment to a page
|
|
56
|
-
* @param config - Confluence configuration
|
|
57
|
-
* @param pageId - Page ID
|
|
58
|
-
* @param body - Comment body
|
|
59
|
-
*/
|
|
60
|
-
export declare function addComment(config: Config, pageId: string, body: string): Promise<ApiResult>;
|
|
61
|
-
/**
|
|
62
|
-
* Delete a comment from a page
|
|
63
|
-
* @param config - Confluence configuration
|
|
64
|
-
* @param id - Comment ID
|
|
65
|
-
*/
|
|
66
|
-
export declare function deleteComment(config: Config, id: string): Promise<ApiResult>;
|
|
67
|
-
/**
|
|
68
|
-
* Update a comment on a page
|
|
69
|
-
* @param config - Confluence configuration
|
|
70
|
-
* @param id - Comment ID
|
|
71
|
-
* @param body - Comment body
|
|
72
|
-
*/
|
|
73
|
-
export declare function updateComment(config: Config, id: string, body: string): Promise<ApiResult>;
|
|
74
|
-
/**
|
|
75
|
-
* Delete a page
|
|
76
|
-
* @param config - Confluence configuration
|
|
77
|
-
* @param pageId - Page ID
|
|
78
|
-
*/
|
|
79
|
-
export declare function deleteContent(config: Config, pageId: string): Promise<ApiResult>;
|
|
80
|
-
/**
|
|
81
|
-
* Test Confluence API connection
|
|
82
|
-
* @param config - Confluence configuration
|
|
83
|
-
*/
|
|
84
|
-
export declare function testConnection(config: Config): Promise<ApiResult>;
|
|
85
|
-
/**
|
|
86
|
-
* Clear clients (for cleanup)
|
|
87
|
-
*/
|
|
88
|
-
export declare function clearClients(): void;
|
|
89
|
-
/**
|
|
90
|
-
* Download attachment from a page
|
|
91
|
-
* @param config - Confluence configuration
|
|
92
|
-
* @param attachmentId - Attachment ID
|
|
93
|
-
* @param outputPath - Output file path (optional)
|
|
94
|
-
*/
|
|
95
|
-
export declare function downloadAttachment(config: Config, attachmentId: string, outputPath?: string): Promise<ApiResult>;
|
|
1
|
+
import { type ApiResult, type AuthConfig } from '@hesed/plugin-lib';
|
|
2
|
+
declare const clearClients: () => void;
|
|
3
|
+
export { clearClients };
|
|
4
|
+
export declare function listSpaces(config: AuthConfig): Promise<ApiResult>;
|
|
5
|
+
export declare function getSpace(config: AuthConfig, spaceKey: string): Promise<ApiResult>;
|
|
6
|
+
export declare function searchContents(config: AuthConfig, cql: string, limit?: number, expand?: string[]): Promise<ApiResult>;
|
|
7
|
+
export declare function getContent(config: AuthConfig, pageId: string): Promise<ApiResult>;
|
|
8
|
+
export declare function createPage(config: AuthConfig, fields: Record<string, unknown>): Promise<ApiResult>;
|
|
9
|
+
export declare function createPageWithMedia(config: AuthConfig, fields: Record<string, unknown>, filePaths: string[]): Promise<ApiResult>;
|
|
10
|
+
export declare function updateContent(config: AuthConfig, pageId: string, fields: Record<string, unknown>): Promise<ApiResult>;
|
|
11
|
+
export declare function addAttachment(config: AuthConfig, pageId: string, filePath: string): Promise<ApiResult>;
|
|
12
|
+
export declare function addComment(config: AuthConfig, pageId: string, body: string): Promise<ApiResult>;
|
|
13
|
+
export declare function deleteComment(config: AuthConfig, id: string): Promise<ApiResult>;
|
|
14
|
+
export declare function updateComment(config: AuthConfig, id: string, body: string): Promise<ApiResult>;
|
|
15
|
+
export declare function deleteContent(config: AuthConfig, pageId: string): Promise<ApiResult>;
|
|
16
|
+
export declare function testConnection(config: AuthConfig): Promise<ApiResult>;
|
|
17
|
+
export declare function downloadAttachment(config: AuthConfig, attachmentId: string, outputPath?: string): Promise<ApiResult>;
|
|
@@ -1,158 +1,60 @@
|
|
|
1
|
+
import { createApiClient } from '@hesed/plugin-lib';
|
|
1
2
|
import { ConniApi } from './conni-api.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Initialize Confluence API
|
|
5
|
-
*/
|
|
6
|
-
async function initConni(config) {
|
|
7
|
-
if (conniApi)
|
|
8
|
-
return conniApi;
|
|
9
|
-
try {
|
|
10
|
-
conniApi = new ConniApi(config);
|
|
11
|
-
return conniApi;
|
|
12
|
-
}
|
|
13
|
-
catch (error) {
|
|
14
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
15
|
-
throw new Error(`Failed to initialize Confluence client: ${errorMessage}`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* List all spaces
|
|
20
|
-
* @param config - Confluence configuration
|
|
21
|
-
*/
|
|
3
|
+
const { clearClients, getClient } = createApiClient('Confluence', (config) => new ConniApi(config));
|
|
4
|
+
export { clearClients };
|
|
22
5
|
export async function listSpaces(config) {
|
|
23
|
-
const conni = await
|
|
6
|
+
const conni = await getClient(config);
|
|
24
7
|
return conni.listSpaces();
|
|
25
8
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Get space details
|
|
28
|
-
* @param config - Confluence configuration
|
|
29
|
-
* @param spaceKey - Space key
|
|
30
|
-
*/
|
|
31
9
|
export async function getSpace(config, spaceKey) {
|
|
32
|
-
const conni = await
|
|
10
|
+
const conni = await getClient(config);
|
|
33
11
|
return conni.getSpace(spaceKey);
|
|
34
12
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Search pages using CQL
|
|
37
|
-
* @param config - Confluence configuration
|
|
38
|
-
* @param cql - CQL query string
|
|
39
|
-
* @param limit - Maximum number of contents per page
|
|
40
|
-
* @param expand - Properties of the content to expand
|
|
41
|
-
*/
|
|
42
13
|
export async function searchContents(config, cql, limit, expand) {
|
|
43
|
-
const conni = await
|
|
14
|
+
const conni = await getClient(config);
|
|
44
15
|
return conni.searchContents(cql, limit, expand);
|
|
45
16
|
}
|
|
46
|
-
/**
|
|
47
|
-
* Get page details
|
|
48
|
-
* @param config - Confluence configuration
|
|
49
|
-
* @param pageId - Page ID
|
|
50
|
-
*/
|
|
51
17
|
export async function getContent(config, pageId) {
|
|
52
|
-
const conni = await
|
|
18
|
+
const conni = await getClient(config);
|
|
53
19
|
return conni.getContent(pageId);
|
|
54
20
|
}
|
|
55
|
-
/**
|
|
56
|
-
* Create a new page
|
|
57
|
-
* @param config - Confluence configuration
|
|
58
|
-
* @param fields - Page fields (spaceKey, title, body, parentId)
|
|
59
|
-
*/
|
|
60
21
|
export async function createPage(config, fields) {
|
|
61
|
-
const conni = await
|
|
22
|
+
const conni = await getClient(config);
|
|
62
23
|
return conni.createPage(fields);
|
|
63
24
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Create a new page with inline media attachments
|
|
66
|
-
* @param config - Confluence configuration
|
|
67
|
-
* @param fields - Page fields (spaceKey, title, body, parentId)
|
|
68
|
-
* @param filePaths - Local file paths to upload and embed inline
|
|
69
|
-
*/
|
|
70
25
|
export async function createPageWithMedia(config, fields, filePaths) {
|
|
71
|
-
const conni = await
|
|
26
|
+
const conni = await getClient(config);
|
|
72
27
|
return conni.createPageWithMedia(fields, filePaths);
|
|
73
28
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Update an existing page
|
|
76
|
-
* @param config - Confluence configuration
|
|
77
|
-
* @param pageId - Page ID
|
|
78
|
-
* @param fields - Page fields to update (title, body)
|
|
79
|
-
*/
|
|
80
29
|
export async function updateContent(config, pageId, fields) {
|
|
81
|
-
const conni = await
|
|
30
|
+
const conni = await getClient(config);
|
|
82
31
|
return conni.updateContent(pageId, fields);
|
|
83
32
|
}
|
|
84
|
-
/**
|
|
85
|
-
* Add an attachment to a page
|
|
86
|
-
* @param config - Confluence configuration
|
|
87
|
-
* @param pageId - Page ID
|
|
88
|
-
* @param filePath - Path to the file to upload
|
|
89
|
-
*/
|
|
90
33
|
export async function addAttachment(config, pageId, filePath) {
|
|
91
|
-
const conni = await
|
|
34
|
+
const conni = await getClient(config);
|
|
92
35
|
return conni.addAttachment(pageId, filePath);
|
|
93
36
|
}
|
|
94
|
-
/**
|
|
95
|
-
* Add a comment to a page
|
|
96
|
-
* @param config - Confluence configuration
|
|
97
|
-
* @param pageId - Page ID
|
|
98
|
-
* @param body - Comment body
|
|
99
|
-
*/
|
|
100
37
|
export async function addComment(config, pageId, body) {
|
|
101
|
-
const conni = await
|
|
38
|
+
const conni = await getClient(config);
|
|
102
39
|
return conni.addComment(pageId, body);
|
|
103
40
|
}
|
|
104
|
-
/**
|
|
105
|
-
* Delete a comment from a page
|
|
106
|
-
* @param config - Confluence configuration
|
|
107
|
-
* @param id - Comment ID
|
|
108
|
-
*/
|
|
109
41
|
export async function deleteComment(config, id) {
|
|
110
|
-
const conni = await
|
|
42
|
+
const conni = await getClient(config);
|
|
111
43
|
return conni.deleteComment(id);
|
|
112
44
|
}
|
|
113
|
-
/**
|
|
114
|
-
* Update a comment on a page
|
|
115
|
-
* @param config - Confluence configuration
|
|
116
|
-
* @param id - Comment ID
|
|
117
|
-
* @param body - Comment body
|
|
118
|
-
*/
|
|
119
45
|
export async function updateComment(config, id, body) {
|
|
120
|
-
const conni = await
|
|
46
|
+
const conni = await getClient(config);
|
|
121
47
|
return conni.updateComment(id, body);
|
|
122
48
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Delete a page
|
|
125
|
-
* @param config - Confluence configuration
|
|
126
|
-
* @param pageId - Page ID
|
|
127
|
-
*/
|
|
128
49
|
export async function deleteContent(config, pageId) {
|
|
129
|
-
const conni = await
|
|
50
|
+
const conni = await getClient(config);
|
|
130
51
|
return conni.deleteContent(pageId);
|
|
131
52
|
}
|
|
132
|
-
/**
|
|
133
|
-
* Test Confluence API connection
|
|
134
|
-
* @param config - Confluence configuration
|
|
135
|
-
*/
|
|
136
53
|
export async function testConnection(config) {
|
|
137
|
-
const conni = await
|
|
54
|
+
const conni = await getClient(config);
|
|
138
55
|
return conni.testConnection();
|
|
139
56
|
}
|
|
140
|
-
/**
|
|
141
|
-
* Clear clients (for cleanup)
|
|
142
|
-
*/
|
|
143
|
-
export function clearClients() {
|
|
144
|
-
if (conniApi) {
|
|
145
|
-
conniApi.clearClients();
|
|
146
|
-
conniApi = null;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Download attachment from a page
|
|
151
|
-
* @param config - Confluence configuration
|
|
152
|
-
* @param attachmentId - Attachment ID
|
|
153
|
-
* @param outputPath - Output file path (optional)
|
|
154
|
-
*/
|
|
155
57
|
export async function downloadAttachment(config, attachmentId, outputPath) {
|
|
156
|
-
const conni = await
|
|
58
|
+
const conni = await getClient(config);
|
|
157
59
|
return conni.downloadAttachment(attachmentId, outputPath);
|
|
158
60
|
}
|