@bagooon/chatease-node-client 0.1.3 → 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 +22 -11
- package/dist/client.d.ts +1 -0
- package/dist/client.js +24 -0
- package/dist/types.d.ts +4 -2
- 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
|
---
|
|
@@ -154,23 +159,17 @@ createBoard(params: CreateBoardBaseParams): Promise<CreateBoardResponse>
|
|
|
154
159
|
### `createBoardWithStatus(params)`
|
|
155
160
|
|
|
156
161
|
```ts
|
|
157
|
-
type ChatEaseStatusKey =
|
|
158
|
-
| 'scheduled_for_proof'
|
|
159
|
-
| 'scheduled_for_response'
|
|
160
|
-
| 'scheduled_for_completion'
|
|
161
|
-
| 'waiting_for_reply'
|
|
162
|
-
|
|
163
162
|
type InitialStatus =
|
|
164
163
|
| {
|
|
165
164
|
statusKey:
|
|
166
|
-
| 'scheduled_for_proof'
|
|
167
|
-
| 'scheduled_for_response'
|
|
168
|
-
| 'scheduled_for_completion'
|
|
165
|
+
| 'scheduled_for_proof' // 校正予定
|
|
166
|
+
| 'scheduled_for_response' // 返答予定
|
|
167
|
+
| 'scheduled_for_completion' // 完了予定
|
|
169
168
|
timeLimit: string // YYYY-MM-DD
|
|
170
169
|
}
|
|
171
170
|
| {
|
|
172
|
-
statusKey: 'waiting_for_reply'
|
|
173
|
-
timeLimit
|
|
171
|
+
statusKey: 'waiting_for_reply' // 返答待ち
|
|
172
|
+
timeLimit: never // 日付は指定できません
|
|
174
173
|
}
|
|
175
174
|
|
|
176
175
|
interface CreateBoardWithStatusParams extends CreateBoardBaseParams {
|
|
@@ -225,6 +224,18 @@ interface CreateBoardResponse {
|
|
|
225
224
|
|
|
226
225
|
---
|
|
227
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
|
+
|
|
228
239
|
## Validation
|
|
229
240
|
|
|
230
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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export type ChatEaseStatusKey = 'scheduled_for_proof' | 'scheduled_for_response' | 'scheduled_for_completion' | 'waiting_for_reply';
|
|
2
1
|
type ScheduledStatusKey = 'scheduled_for_proof' | 'scheduled_for_response' | 'scheduled_for_completion';
|
|
3
2
|
type NonScheduledStatusKey = 'waiting_for_reply';
|
|
4
3
|
export type InitialStatus = {
|
|
@@ -13,7 +12,7 @@ export type InitialStatus = {
|
|
|
13
12
|
/**
|
|
14
13
|
* scheduled 以外は timeLimit を指定させない
|
|
15
14
|
*/
|
|
16
|
-
timeLimit
|
|
15
|
+
timeLimit: never;
|
|
17
16
|
};
|
|
18
17
|
export interface ChatEaseClientOptions {
|
|
19
18
|
apiToken: string;
|
|
@@ -51,4 +50,7 @@ export interface CreateBoardResponse {
|
|
|
51
50
|
hostURL: string;
|
|
52
51
|
guestURL: string;
|
|
53
52
|
}
|
|
53
|
+
export interface WorkspaceNameResponse {
|
|
54
|
+
name: string;
|
|
55
|
+
}
|
|
54
56
|
export {};
|