@theholocron/confluence-client 0.1.0 → 0.2.1
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 +52 -8
- package/dist/index.d.mts +19 -4
- package/dist/index.mjs +22 -24
- package/package.json +37 -34
package/README.md
CHANGED
|
@@ -1,19 +1,63 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @theholocron/confluence-client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript client for the Confluence REST API.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
8
|
+
pnpm add @theholocron/confluence-client
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
```
|
|
14
|
-
import
|
|
13
|
+
```ts
|
|
14
|
+
import { createConfluenceClient } from "@theholocron/confluence-client";
|
|
15
15
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const confluence = createConfluenceClient({
|
|
17
|
+
baseUrl: "https://myorg.atlassian.net/wiki/rest/api",
|
|
18
|
+
token: Buffer.from("agent@example.com:your-api-token").toString("base64"),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Pages
|
|
22
|
+
const page = await confluence.page.get("123456");
|
|
23
|
+
|
|
24
|
+
await confluence.page.update("123456", {
|
|
25
|
+
version: { number: 2 },
|
|
26
|
+
title: "Updated page title",
|
|
27
|
+
body: {
|
|
28
|
+
storage: { value: "<p>New content</p>", representation: "storage" },
|
|
29
|
+
},
|
|
30
|
+
});
|
|
19
31
|
```
|
|
32
|
+
|
|
33
|
+
## Auth
|
|
34
|
+
|
|
35
|
+
Confluence Cloud uses HTTP Basic auth with a base64-encoded `email:apiToken` string. Generate an API token at [id.atlassian.com/manage-profile/security/api-tokens](https://id.atlassian.com/manage-profile/security/api-tokens).
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
const token = Buffer.from("agent@example.com:your-api-token").toString(
|
|
39
|
+
"base64",
|
|
40
|
+
);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## API
|
|
44
|
+
|
|
45
|
+
### `createConfluenceClient(opts)`
|
|
46
|
+
|
|
47
|
+
| Option | Type | Description |
|
|
48
|
+
| --------- | -------- | -------------------------------------------------------------------------------- |
|
|
49
|
+
| `baseUrl` | `string` | Confluence REST API base URL, e.g. `"https://myorg.atlassian.net/wiki/rest/api"` |
|
|
50
|
+
| `token` | `string` | Base64-encoded `email:apiToken` |
|
|
51
|
+
|
|
52
|
+
Returns a client with a `page` namespace.
|
|
53
|
+
|
|
54
|
+
### `client.page`
|
|
55
|
+
|
|
56
|
+
| Method | Description |
|
|
57
|
+
| --------------------- | --------------------------------------------------- |
|
|
58
|
+
| `get<T>(id)` | Fetch a page by ID |
|
|
59
|
+
| `update<T>(id, data)` | Update a page (requires `version.number` increment) |
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
GPL-3.0 © [Newton Koumantzelis](https://github.com/iamnewton)
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
+
import { RestClient } from "@theholocron/http-client";
|
|
2
|
+
//#region src/page/page.d.ts
|
|
3
|
+
declare function page(rest: RestClient): {
|
|
4
|
+
get: <T = unknown>(id: string) => Promise<T>;
|
|
5
|
+
update: <T = unknown>(id: string, data: Record<string, unknown>) => Promise<T>;
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
1
8
|
//#region src/index.d.ts
|
|
2
|
-
|
|
9
|
+
interface ConfluenceClientOptions {
|
|
10
|
+
/** Base URL including the API path, e.g. "https://myorg.atlassian.net/wiki/rest/api". */
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
/** Base64-encoded "email:apiToken" — use Buffer.from("email:token").toString("base64"). */
|
|
13
|
+
token: string;
|
|
14
|
+
/** Override fetch for testing. Defaults to globalThis.fetch. */
|
|
15
|
+
fetch?: typeof fetch;
|
|
16
|
+
}
|
|
17
|
+
declare function createConfluenceClient(opts: ConfluenceClientOptions): {
|
|
3
18
|
page: {
|
|
4
|
-
get: (id: string
|
|
5
|
-
update: (id: string, data: Record<string, unknown
|
|
19
|
+
get: <T = unknown>(id: string) => Promise<T>;
|
|
20
|
+
update: <T = unknown>(id: string, data: Record<string, unknown>) => Promise<T>;
|
|
6
21
|
};
|
|
7
22
|
};
|
|
8
23
|
//#endregion
|
|
9
|
-
export {
|
|
24
|
+
export { ConfluenceClientOptions, createConfluenceClient, page };
|
package/dist/index.mjs
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { exreq, setBaseURL } from "@ce/utils-fetch";
|
|
1
|
+
import { createRestClient } from "@theholocron/http-client";
|
|
3
2
|
//#region src/page/page.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
operation: id,
|
|
14
|
-
method: "put",
|
|
15
|
-
data,
|
|
16
|
-
options: {
|
|
17
|
-
...options,
|
|
18
|
-
baseURL: setBaseURL("atlassian", appConf, options?.environment)
|
|
19
|
-
}
|
|
20
|
-
});
|
|
3
|
+
function page(rest) {
|
|
4
|
+
return {
|
|
5
|
+
get: (id) => rest.request(`/${id}`),
|
|
6
|
+
update: (id, data) => rest.request(`/${id}`, {
|
|
7
|
+
method: "PUT",
|
|
8
|
+
body: data
|
|
9
|
+
})
|
|
10
|
+
};
|
|
11
|
+
}
|
|
21
12
|
//#endregion
|
|
22
13
|
//#region src/index.ts
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
function createConfluenceRestClient(opts) {
|
|
15
|
+
return createRestClient({
|
|
16
|
+
baseUrl: opts.baseUrl,
|
|
17
|
+
token: opts.token,
|
|
18
|
+
vendor: "Confluence",
|
|
19
|
+
fetch: opts.fetch
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function createConfluenceClient(opts) {
|
|
23
|
+
return { page: page(createConfluenceRestClient(opts)) };
|
|
24
|
+
}
|
|
27
25
|
//#endregion
|
|
28
|
-
export {
|
|
26
|
+
export { createConfluenceClient, page };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/confluence-client",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A TypeScript client for the Confluence API",
|
|
5
5
|
"homepage": "https://github.com/theholocron/clients/tree/main/packages/confluence-client#readme",
|
|
6
6
|
"bugs": "https://github.com/theholocron/clients/issues",
|
|
@@ -12,48 +12,51 @@
|
|
|
12
12
|
"license": "GPL-3.0",
|
|
13
13
|
"author": "Newton Koumantzelis",
|
|
14
14
|
"type": "module",
|
|
15
|
-
"main": "./
|
|
15
|
+
"main": "./dist/index.mjs",
|
|
16
16
|
"exports": {
|
|
17
|
-
".":
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.mts",
|
|
19
|
+
"import": "./dist/index.mjs",
|
|
20
|
+
"default": "./dist/index.mjs"
|
|
21
|
+
}
|
|
18
22
|
},
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"lint": "eslint .",
|
|
22
|
-
"test": "vitest run",
|
|
23
|
-
"test:watch": "vitest",
|
|
24
|
-
"test:coverage": "vitest run --coverage",
|
|
25
|
-
"typecheck": "tsc --noEmit"
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@theholocron/http-client": "^0.1.0"
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
28
|
-
"@
|
|
29
|
-
"@theholocron/
|
|
30
|
-
"@theholocron/
|
|
31
|
-
"@theholocron/
|
|
32
|
-
"@vitest
|
|
33
|
-
"@vitest/
|
|
34
|
-
"eslint": "
|
|
35
|
-
"eslint
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
27
|
+
"@types/node": "^22.0.0",
|
|
28
|
+
"@theholocron/eslint-config": "^6.0.0",
|
|
29
|
+
"@theholocron/tsconfig": "^6.0.0",
|
|
30
|
+
"@theholocron/tsdown-config": "^6.0.0",
|
|
31
|
+
"@theholocron/vitest-config": "^6.0.0",
|
|
32
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
33
|
+
"@vitest/eslint-plugin": "^1.6.23",
|
|
34
|
+
"eslint": "^10.7.0",
|
|
35
|
+
"eslint-plugin-n": "^18.2.2",
|
|
36
|
+
"globals": "^17.7.0",
|
|
37
|
+
"tsdown": "^0.22.5",
|
|
38
|
+
"typescript": "^5.9.3",
|
|
39
|
+
"vitest": "^4.1.10"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
|
-
"access": "public"
|
|
43
|
-
"main": "./dist/index.mjs",
|
|
44
|
-
"types": "./dist/index.d.mts",
|
|
45
|
-
"exports": {
|
|
46
|
-
".": {
|
|
47
|
-
"types": "./dist/index.d.mts",
|
|
48
|
-
"import": "./dist/index.mjs",
|
|
49
|
-
"default": "./dist/index.mjs"
|
|
50
|
-
}
|
|
51
|
-
}
|
|
42
|
+
"access": "public"
|
|
52
43
|
},
|
|
53
44
|
"files": [
|
|
54
45
|
"dist",
|
|
55
46
|
"README.md"
|
|
56
47
|
],
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=22.0.0"
|
|
50
|
+
},
|
|
57
51
|
"releases": "https://github.com/theholocron/clients/releases",
|
|
58
|
-
"wiki": "https://github.com/theholocron/clients/wiki"
|
|
59
|
-
|
|
52
|
+
"wiki": "https://github.com/theholocron/clients/wiki",
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsdown",
|
|
55
|
+
"lint": "eslint .",
|
|
56
|
+
"test": "vitest run",
|
|
57
|
+
"test:watch": "vitest",
|
|
58
|
+
"test:coverage": "vitest run --coverage",
|
|
59
|
+
"typecheck": "tsc --noEmit"
|
|
60
|
+
},
|
|
61
|
+
"types": "./dist/index.d.mts"
|
|
62
|
+
}
|