@noti-bot/sdk 0.8.0 → 0.9.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 CHANGED
@@ -29,6 +29,15 @@ Node.js 20 이상, ESM을 지원합니다. API 키는 브라우저 번들에 넣
29
29
 
30
30
  `queued: true`는 접수이며 실제 전달 성공이 아닙니다. 서버는 API 키별 `requestId`로 중복을 방지합니다. 같은 논리적 발송에는 같은 ID를 사용하세요. **SDK는 POST 또는 GET을 자동 재시도하지 않습니다.** 타임아웃은 이미 접수된 요청일 수 있으므로 새 ID로 재시도하면 중복 발송됩니다. `NotiBotTransportError.requestId`로 요청을 식별하고 대시보드 로그를 확인하세요.
31
31
 
32
+ ## 전달 결과 확인
33
+
34
+ ```ts
35
+ const r = await kakao.getMessage('deploy:release-2026-10-10');
36
+ // r.status: 'queued' | 'sent' | 'failed' | 'expired' | 'duplicate', r.sent: true | false | null, r.error
37
+ ```
38
+
39
+ 이 API 키로 보낸 `requestId`만 조회됩니다(`messages:send` 필요). 없거나 다른 키가 보낸 ID면 `404 message_not_found`. `failed` + `error: 'delivery_unknown'`은 폰이 가져갔지만 결과를 못 받은 상태라 실제로 갔을 수 있습니다. 중복이 괜찮을 때만 **새** `requestId`로 다시 보내세요.
40
+
32
41
  ## 멘션
33
42
 
34
43
  받은 웹훅의 `mentions`에는 메시지가 실제로 태그한 계정이 `{ userId, name? }`로 들어옵니다. 이름은 바뀔 수 있으니 `userId`로 비교하세요.
@@ -99,6 +108,7 @@ try {
99
108
 
100
109
  ## 변경 이력
101
110
 
111
+ - **0.9.0** — `getMessage(requestId)`: 보낸 메시지의 전달 결과(`GET /v1/messages/{requestId}`).
102
112
  - **0.8.0** — 워크스페이스 API 키(`nb_live_`/`nb_test_`). `kb_` 키는 더 이상 동작하지 않음. 콘솔에서 새로 발급해 교체하세요. `room_not_bound` 대신 `404 room_not_found`.
103
113
 
104
114
  ## 릴리스
package/dist/errors.d.ts CHANGED
@@ -19,7 +19,7 @@
19
19
  */
20
20
  export declare const NOTIBOT_ERROR_BRAND: unique symbol;
21
21
  /** 허브가 돌려주는 오류 코드. 서버 라우트(`src/outbound/routes.ts`)가 정본이다. */
22
- export declare const NOTIBOT_ERROR_CODES: readonly ["validation_error", "invalid_room_slug", "unauthorized", "plan_message_limit", "insufficient_scope", "room_not_found", "room_inactive", "idempotency_conflict", "rate_limited", "kill_switch", "queue_full", "request_failed"];
22
+ export declare const NOTIBOT_ERROR_CODES: readonly ["validation_error", "invalid_room_slug", "unauthorized", "plan_message_limit", "insufficient_scope", "room_not_found", "message_not_found", "room_inactive", "idempotency_conflict", "rate_limited", "kill_switch", "queue_full", "request_failed"];
23
23
  export type NotiBotErrorCode = (typeof NOTIBOT_ERROR_CODES)[number];
24
24
  /**
25
25
  * 알려진 코드는 자동완성으로 뜨되, 허브가 새 코드를 추가해도 타입이 깨지지 않는다.
package/dist/errors.js CHANGED
@@ -26,6 +26,7 @@ export const NOTIBOT_ERROR_CODES = [
26
26
  "plan_message_limit",
27
27
  "insufficient_scope",
28
28
  "room_not_found",
29
+ "message_not_found",
29
30
  "room_inactive",
30
31
  "idempotency_conflict",
31
32
  "rate_limited",
package/dist/index.d.ts CHANGED
@@ -47,6 +47,22 @@ export interface SendMessageResult {
47
47
  request_id: string;
48
48
  room?: string;
49
49
  }
50
+ /** Hub-side delivery state of one sent message. */
51
+ export type MessageStatus = "queued" | "sent" | "failed" | "expired" | "duplicate";
52
+ /** Delivery result for a `requestId` sent with this API key. */
53
+ export interface MessageResult {
54
+ request_id: string;
55
+ room: string;
56
+ status: MessageStatus;
57
+ /** true: the phone handed it to KakaoTalk. false: rejected. null: still queued, or unknown. */
58
+ sent: boolean | null;
59
+ /** e.g. `delivery_unknown`, `no_session`, `expired_in_queue`. */
60
+ error: string | null;
61
+ /** Accepted at (epoch ms). */
62
+ at: number;
63
+ /** Phone result at (epoch ms), or null. */
64
+ sent_at: number | null;
65
+ }
50
66
  export interface Room {
51
67
  id?: string;
52
68
  slug?: string | null;
@@ -106,6 +122,13 @@ export declare class NotiBot {
106
122
  private readonly fetchFn;
107
123
  constructor(options: NotiBotOptions);
108
124
  sendMessage(input: SendMessageInput, options?: RequestOptions): Promise<SendMessageResult>;
125
+ /**
126
+ * Delivery result of a message this API key sent. Requires the `messages:send` scope.
127
+ * Rejects with `message_not_found` for unknown IDs, IDs of other keys, and test-key sends.
128
+ * `failed` + `delivery_unknown` means the phone may or may not have sent it: retry with a
129
+ * new requestId only when a duplicate is acceptable.
130
+ */
131
+ getMessage(requestId: string, options?: RequestOptions): Promise<MessageResult>;
109
132
  listRooms(options?: RequestOptions): Promise<Room[]>;
110
133
  /** Members of a room in this workspace. Requires the `rooms:read` scope. */
111
134
  listRoomMembers(room: {
package/dist/index.js CHANGED
@@ -69,6 +69,27 @@ export class NotiBot {
69
69
  throw new NotiBotProtocolError(requestId);
70
70
  return data;
71
71
  }
72
+ /**
73
+ * Delivery result of a message this API key sent. Requires the `messages:send` scope.
74
+ * Rejects with `message_not_found` for unknown IDs, IDs of other keys, and test-key sends.
75
+ * `failed` + `delivery_unknown` means the phone may or may not have sent it: retry with a
76
+ * new requestId only when a duplicate is acceptable.
77
+ */
78
+ async getMessage(requestId, options = {}) {
79
+ if (!requestId.trim() || requestId.length > 128)
80
+ throw new TypeError("requestId must contain 1 to 128 characters.");
81
+ const data = await this.request(`/v1/messages/${encodeURIComponent(requestId)}`, "GET", undefined, options.signal, requestId);
82
+ if (!object(data) ||
83
+ data.request_id !== requestId ||
84
+ typeof data.room !== "string" ||
85
+ !["queued", "sent", "failed", "expired", "duplicate"].includes(String(data.status)) ||
86
+ !(data.sent === null || typeof data.sent === "boolean") ||
87
+ !(data.error === null || typeof data.error === "string") ||
88
+ typeof data.at !== "number" ||
89
+ !(data.sent_at === null || typeof data.sent_at === "number"))
90
+ throw new NotiBotProtocolError(requestId);
91
+ return data;
92
+ }
72
93
  async listRooms(options = {}) {
73
94
  const data = await this.request("/v1/rooms", "GET", undefined, options.signal);
74
95
  if (!object(data) ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noti-bot/sdk",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Typed server-side client for the NotiBot API",
5
5
  "license": "MIT",
6
6
  "author": "Jeongmin Lee",