@bagooon/chatease-node-client 0.1.4 → 0.2.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 +17 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +24 -0
- package/dist/types.d.ts +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ Node.js 向けの **[ChatEase](https://chatease.jp "ChatEase.jp") チャット
|
|
|
21
21
|
- チャットボード生成のみ
|
|
22
22
|
- チャットボード + 初期ステータス
|
|
23
23
|
- チャットボード + 初期ステータス + 初期投稿
|
|
24
|
+
- ワークスペース名取得メソッド `getWorkspaceName()` を提供
|
|
24
25
|
- TypeScript フルサポート(型定義同梱)
|
|
25
26
|
- 実行時バリデーション
|
|
26
27
|
- `timeLimit` の日付妥当性(`YYYY-MM-DD` & 実在日付)
|
|
@@ -101,6 +102,10 @@ const res3 = await chatease.createBoardWithStatusAndMessage({
|
|
|
101
102
|
content: 'ロゴデザインについて相談したいです。現在の案を添付しました。',
|
|
102
103
|
},
|
|
103
104
|
})
|
|
105
|
+
|
|
106
|
+
// 4) ワークスペース名を取得
|
|
107
|
+
// (APIトークン+ワークスペーススラッグが正しく設定されているかを確認する用途に利用できます。)
|
|
108
|
+
const workdpaceName = await chatease.getWorkspaceName()
|
|
104
109
|
```
|
|
105
110
|
|
|
106
111
|
---
|
|
@@ -219,6 +224,18 @@ interface CreateBoardResponse {
|
|
|
219
224
|
|
|
220
225
|
---
|
|
221
226
|
|
|
227
|
+
### `getWorkspaceName()`
|
|
228
|
+
|
|
229
|
+
```ts
|
|
230
|
+
getWorkspaceName(): Promise<string>
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
認証には既存の API トークンヘッダー(`X-Chatease-API-Token`)と、リクエストボディの `workspaceSlug` を使用します。
|
|
234
|
+
APIトークン+ワークスペーススラッグが正しく設定されているかを確認する用途に利用できます。
|
|
235
|
+
認証に失敗した場合は、例外を投げます。
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
222
239
|
## Validation
|
|
223
240
|
|
|
224
241
|
このクライアントは、API 呼び出し前に以下の実行時チェックを行います:
|
package/dist/client.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare class ChatEaseClient {
|
|
|
7
7
|
createBoard(params: CreateBoardBaseParams): Promise<CreateBoardResponse>;
|
|
8
8
|
createBoardWithStatus(params: CreateBoardWithStatusParams): Promise<CreateBoardResponse>;
|
|
9
9
|
createBoardWithStatusAndMessage(params: CreateBoardWithStatusAndMessageParams): Promise<CreateBoardResponse>;
|
|
10
|
+
getWorkspaceName(): Promise<string>;
|
|
10
11
|
/**
|
|
11
12
|
* 実処理 + 共通バリデーション
|
|
12
13
|
*/
|
package/dist/client.js
CHANGED
|
@@ -26,6 +26,30 @@ export class ChatEaseClient {
|
|
|
26
26
|
async createBoardWithStatusAndMessage(params) {
|
|
27
27
|
return this._createBoard(params);
|
|
28
28
|
}
|
|
29
|
+
async getWorkspaceName() {
|
|
30
|
+
const res = await fetch(this.buildUrl('/api/v1/board/name'), {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
headers: {
|
|
33
|
+
'Content-Type': 'application/json',
|
|
34
|
+
'X-Chatease-API-Token': this.apiToken,
|
|
35
|
+
},
|
|
36
|
+
body: JSON.stringify({
|
|
37
|
+
workspaceSlug: this.workspaceSlug,
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
40
|
+
if (!res.ok) {
|
|
41
|
+
const text = await res.text().catch(() => '');
|
|
42
|
+
const message = [
|
|
43
|
+
`ChatEase API error: ${res.status} ${res.statusText}`,
|
|
44
|
+
text && `Body: ${text}`,
|
|
45
|
+
]
|
|
46
|
+
.filter(Boolean)
|
|
47
|
+
.join(' - ');
|
|
48
|
+
throw new Error(message);
|
|
49
|
+
}
|
|
50
|
+
const json = (await res.json());
|
|
51
|
+
return json.name;
|
|
52
|
+
}
|
|
29
53
|
/**
|
|
30
54
|
* 実処理 + 共通バリデーション
|
|
31
55
|
*/
|
package/dist/types.d.ts
CHANGED