@teamlearners/clawops 0.27.0 → 0.29.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/dist/index.d.ts CHANGED
@@ -56,12 +56,30 @@ declare class APIClient {
56
56
  extraQuery?: Record<string, unknown>;
57
57
  timeout?: number;
58
58
  }): Promise<T>;
59
+ _patch<T>(path: string, options: {
60
+ body?: Record<string, unknown> | null;
61
+ castTo: z.ZodType<T>;
62
+ extraHeaders?: Record<string, string>;
63
+ extraQuery?: Record<string, unknown>;
64
+ timeout?: number;
65
+ }): Promise<T>;
59
66
  _getRaw(path: string, options?: {
60
67
  query?: Record<string, unknown> | null;
61
68
  extraHeaders?: Record<string, string>;
62
69
  extraQuery?: Record<string, unknown>;
63
70
  timeout?: number;
64
71
  }): Promise<Response>;
72
+ /**
73
+ * 본문을 돌려주는 DELETE. 기존 `_delete` 는 void 라 응답을 버리는데, soft delete 처럼
74
+ * 삭제 결과 리소스를 그대로 반환하는 endpoint 가 있어서 따로 둔다.
75
+ */
76
+ _deleteWithResponse<T>(path: string, options: {
77
+ body?: Record<string, unknown> | null;
78
+ castTo: z.ZodType<T>;
79
+ extraHeaders?: Record<string, string>;
80
+ extraQuery?: Record<string, unknown>;
81
+ timeout?: number;
82
+ }): Promise<T>;
65
83
  _delete(path: string, options?: {
66
84
  extraHeaders?: Record<string, string>;
67
85
  timeout?: number;
@@ -212,7 +230,7 @@ type AssignmentLink = z.infer<typeof AssignmentLinkSchema>;
212
230
  type AssignmentLinkCreateResponse = z.infer<typeof AssignmentLinkCreateResponseSchema>;
213
231
  type AssignmentLinkStatus = AssignmentLink['status'];
214
232
 
215
- type RequestOptions = {
233
+ type RequestOptions$2 = {
216
234
  extraHeaders?: Record<string, string>;
217
235
  extraQuery?: Record<string, unknown>;
218
236
  timeout?: number;
@@ -228,19 +246,142 @@ declare class AssignmentLinks extends APIResource {
228
246
  webhookUrl?: string;
229
247
  webhookMethod?: 'POST' | 'GET';
230
248
  note?: string;
231
- }, options?: RequestOptions): Promise<AssignmentLinkCreateResponse>;
249
+ }, options?: RequestOptions$2): Promise<AssignmentLinkCreateResponse>;
232
250
  list(params?: {
233
251
  status?: AssignmentLinkStatus;
234
252
  page?: number;
235
253
  pageSize?: number;
236
- }, options?: RequestOptions): Promise<Page<AssignmentLink>>;
237
- retrieve(linkId: string, options?: RequestOptions): Promise<AssignmentLink>;
254
+ }, options?: RequestOptions$2): Promise<Page<AssignmentLink>>;
255
+ retrieve(linkId: string, options?: RequestOptions$2): Promise<AssignmentLink>;
238
256
  revoke(linkId: string, options?: {
239
257
  extraHeaders?: Record<string, string>;
240
258
  timeout?: number;
241
259
  }): Promise<void>;
242
260
  }
243
261
 
262
+ declare const BlockedRecipientSchema: z.ZodObject<{
263
+ id: z.ZodString;
264
+ /** 국내 표기로 정규화된 번호 (예 '01012345678'). */
265
+ number: z.ZodString;
266
+ channel: z.ZodEnum<["call", "message"]>;
267
+ /** 지금 차단 중인지. 해제분도 이력으로 조회되므로 이 값으로 구분한다. */
268
+ active: z.ZodBoolean;
269
+ source: z.ZodString;
270
+ sourceRef: z.ZodOptional<z.ZodNullable<z.ZodString>>;
271
+ note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
272
+ createdBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
273
+ createdAt: z.ZodString;
274
+ updatedAt: z.ZodString;
275
+ unblockedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
276
+ unblockedSource: z.ZodOptional<z.ZodNullable<z.ZodString>>;
277
+ unblockedBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
278
+ unblockedNote: z.ZodOptional<z.ZodNullable<z.ZodString>>;
279
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
280
+ id: z.ZodString;
281
+ /** 국내 표기로 정규화된 번호 (예 '01012345678'). */
282
+ number: z.ZodString;
283
+ channel: z.ZodEnum<["call", "message"]>;
284
+ /** 지금 차단 중인지. 해제분도 이력으로 조회되므로 이 값으로 구분한다. */
285
+ active: z.ZodBoolean;
286
+ source: z.ZodString;
287
+ sourceRef: z.ZodOptional<z.ZodNullable<z.ZodString>>;
288
+ note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
289
+ createdBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
290
+ createdAt: z.ZodString;
291
+ updatedAt: z.ZodString;
292
+ unblockedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
293
+ unblockedSource: z.ZodOptional<z.ZodNullable<z.ZodString>>;
294
+ unblockedBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
295
+ unblockedNote: z.ZodOptional<z.ZodNullable<z.ZodString>>;
296
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
297
+ id: z.ZodString;
298
+ /** 국내 표기로 정규화된 번호 (예 '01012345678'). */
299
+ number: z.ZodString;
300
+ channel: z.ZodEnum<["call", "message"]>;
301
+ /** 지금 차단 중인지. 해제분도 이력으로 조회되므로 이 값으로 구분한다. */
302
+ active: z.ZodBoolean;
303
+ source: z.ZodString;
304
+ sourceRef: z.ZodOptional<z.ZodNullable<z.ZodString>>;
305
+ note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
306
+ createdBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
307
+ createdAt: z.ZodString;
308
+ updatedAt: z.ZodString;
309
+ unblockedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
310
+ unblockedSource: z.ZodOptional<z.ZodNullable<z.ZodString>>;
311
+ unblockedBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
312
+ unblockedNote: z.ZodOptional<z.ZodNullable<z.ZodString>>;
313
+ }, z.ZodTypeAny, "passthrough">>;
314
+ type BlockedRecipient = z.infer<typeof BlockedRecipientSchema>;
315
+ type BlockedChannel = BlockedRecipient['channel'];
316
+ type BlockedRecipientStatus = 'active' | 'released' | 'all';
317
+ type BlockedRecipientSource = 'api' | 'console' | 'import';
318
+
319
+ type RequestOptions$1 = {
320
+ extraHeaders?: Record<string, string>;
321
+ extraQuery?: Record<string, unknown>;
322
+ timeout?: number;
323
+ };
324
+ /**
325
+ * 수신거부(DNC) 명단 리소스.
326
+ *
327
+ * 등록된 번호는 이 계정의 **발신**(전화·문자)에서 제외됩니다. 착신은 막지 않습니다 —
328
+ * 그 번호에서 걸려오는 전화는 그대로 받습니다.
329
+ *
330
+ * 전화와 문자는 각각 따로 차단합니다. 같은 번호라도 채널마다 별개 항목이므로,
331
+ * 둘 다 막으려면 `channel` 을 바꿔 두 번 등록합니다.
332
+ */
333
+ declare class BlockedRecipients extends APIResource {
334
+ /**
335
+ * 번호를 수신거부 명단에 등록합니다.
336
+ *
337
+ * 하이픈·`+82` 표기 모두 허용되며 국내 표기로 정규화되어 저장됩니다.
338
+ *
339
+ * **멱등입니다** — 이미 차단 중인 (번호, 채널)을 다시 등록해도 에러가 아니라 기존 항목을
340
+ * 돌려줍니다. 같은 사람이 수신거부를 두 번 요청하는 것은 정상 상황이기 때문입니다.
341
+ */
342
+ create(params: {
343
+ number: string;
344
+ channel: BlockedChannel;
345
+ source?: BlockedRecipientSource;
346
+ sourceRef?: string;
347
+ note?: string;
348
+ }, options?: RequestOptions$1): Promise<BlockedRecipient>;
349
+ /**
350
+ * 수신거부 목록을 조회합니다. 기본은 **현재 차단 중인 항목만** 이며,
351
+ * 해제 이력까지 보려면 `status` 를 `'released'` 또는 `'all'` 로 지정합니다.
352
+ */
353
+ list(params?: {
354
+ channel?: BlockedChannel;
355
+ number?: string;
356
+ status?: BlockedRecipientStatus;
357
+ page?: number;
358
+ pageSize?: number;
359
+ }, options?: RequestOptions$1): Promise<Page<BlockedRecipient>>;
360
+ /** 항목 상세를 조회합니다. 해제된 항목도 이력으로 남아 조회됩니다(`active: false`). */
361
+ retrieve(blockId: string, options?: RequestOptions$1): Promise<BlockedRecipient>;
362
+ /**
363
+ * 메모를 수정합니다.
364
+ *
365
+ * 번호와 채널은 바꿀 수 없습니다 — 바꾸면 "누가 무엇을 언제 거부했는가"라는 증빙이
366
+ * 뒤틀립니다. 잘못 등록했다면 해제한 뒤 올바른 번호로 새로 등록하세요.
367
+ */
368
+ update(blockId: string, params?: {
369
+ note?: string | null;
370
+ }, options?: RequestOptions$1): Promise<BlockedRecipient>;
371
+ /**
372
+ * 수신거부를 해제해 다시 발신할 수 있게 합니다.
373
+ *
374
+ * **항목은 삭제되지 않습니다.** `active` 가 false 가 되고 `unblockedAt` 이 기록될 뿐,
375
+ * 행은 이력으로 남습니다 — 언제 거부했고 언제 풀렸는지가 곧 증빙이기 때문입니다.
376
+ * 해제분은 `list({ status: 'released' })` 로 볼 수 있습니다.
377
+ *
378
+ * 이미 해제된 항목에 다시 호출해도 성공하며, 최초 해제 시각은 덮어쓰지 않습니다.
379
+ */
380
+ release(blockId: string, params?: {
381
+ note?: string;
382
+ }, options?: RequestOptions$1): Promise<BlockedRecipient>;
383
+ }
384
+
244
385
  declare const CallSchema: z.ZodObject<{
245
386
  callId: z.ZodString;
246
387
  /**
@@ -697,70 +838,156 @@ declare class Messages extends APIResource {
697
838
  }): Promise<Message>;
698
839
  }
699
840
 
841
+ /**
842
+ * 착신 라우팅 모드.
843
+ *
844
+ * - `webhook` : webhookUrl 의 VoiceML 이 처리.
845
+ * - `agent` : agentId 의 매니지드 에이전트가 착신.
846
+ * - `callflow` : callFlowId 의 콜 플로우(ARS)가 착신.
847
+ * - `forward` : forwardTo(같은 계정 보유 번호)로 내부 착신전환.
848
+ * - `sip` : sipEndpointId 의 라우트로 외부 PBX 다이얼.
849
+ * - `softphone` : sipCredentialId 의 등록 단말로 착신.
850
+ */
851
+ declare const ROUTING_TYPES: readonly ["webhook", "sip", "softphone", "forward", "agent", "callflow"];
852
+ type RoutingType = (typeof ROUTING_TYPES)[number];
700
853
  declare const PhoneNumberSchema: z.ZodObject<{
701
854
  number: z.ZodString;
855
+ numberType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
702
856
  source: z.ZodOptional<z.ZodNullable<z.ZodString>>;
703
- webhookUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
704
- webhookMethod: z.ZodOptional<z.ZodNullable<z.ZodEnum<["POST", "GET"]>>>;
705
- routingType: z.ZodOptional<z.ZodNullable<z.ZodEnum<["webhook", "sip", "softphone"]>>>;
857
+ routingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
858
+ agentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
859
+ callFlowId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
860
+ forwardTo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
706
861
  sipEndpointId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
707
862
  sipCredentialId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
863
+ webhookUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
864
+ webhookMethod: z.ZodOptional<z.ZodNullable<z.ZodString>>;
865
+ webhookHeaders: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
866
+ callContextUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
867
+ statusCallback: z.ZodOptional<z.ZodNullable<z.ZodString>>;
868
+ statusCallbackEvents: z.ZodOptional<z.ZodNullable<z.ZodString>>;
869
+ dictionaryId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
708
870
  createdAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
709
871
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
710
872
  number: z.ZodString;
873
+ numberType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
711
874
  source: z.ZodOptional<z.ZodNullable<z.ZodString>>;
712
- webhookUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
713
- webhookMethod: z.ZodOptional<z.ZodNullable<z.ZodEnum<["POST", "GET"]>>>;
714
- routingType: z.ZodOptional<z.ZodNullable<z.ZodEnum<["webhook", "sip", "softphone"]>>>;
875
+ routingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
876
+ agentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
877
+ callFlowId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
878
+ forwardTo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
715
879
  sipEndpointId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
716
880
  sipCredentialId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
881
+ webhookUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
882
+ webhookMethod: z.ZodOptional<z.ZodNullable<z.ZodString>>;
883
+ webhookHeaders: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
884
+ callContextUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
885
+ statusCallback: z.ZodOptional<z.ZodNullable<z.ZodString>>;
886
+ statusCallbackEvents: z.ZodOptional<z.ZodNullable<z.ZodString>>;
887
+ dictionaryId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
717
888
  createdAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
718
889
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
719
890
  number: z.ZodString;
891
+ numberType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
720
892
  source: z.ZodOptional<z.ZodNullable<z.ZodString>>;
721
- webhookUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
722
- webhookMethod: z.ZodOptional<z.ZodNullable<z.ZodEnum<["POST", "GET"]>>>;
723
- routingType: z.ZodOptional<z.ZodNullable<z.ZodEnum<["webhook", "sip", "softphone"]>>>;
893
+ routingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
894
+ agentId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
895
+ callFlowId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
896
+ forwardTo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
724
897
  sipEndpointId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
725
898
  sipCredentialId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
899
+ webhookUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
900
+ webhookMethod: z.ZodOptional<z.ZodNullable<z.ZodString>>;
901
+ webhookHeaders: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
902
+ callContextUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
903
+ statusCallback: z.ZodOptional<z.ZodNullable<z.ZodString>>;
904
+ statusCallbackEvents: z.ZodOptional<z.ZodNullable<z.ZodString>>;
905
+ dictionaryId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
726
906
  createdAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
727
907
  }, z.ZodTypeAny, "passthrough">>;
728
- type PhoneNumber = z.infer<typeof PhoneNumberSchema>;
908
+ /**
909
+ * 전화번호. `routingType` 은 알려진 값에 자동완성이 뜨지만, 서버가 새 라우팅을 추가해도
910
+ * 파싱이 깨지지 않도록 임의의 문자열을 허용한다.
911
+ */
912
+ type PhoneNumber = Omit<z.infer<typeof PhoneNumberSchema>, 'routingType'> & {
913
+ routingType?: RoutingType | (string & {}) | null;
914
+ };
729
915
  type NumberListItem = PhoneNumber;
730
916
  type NumberUpdateResponse = PhoneNumber;
731
917
 
732
918
  interface NumberCreateParams {
919
+ /** 수신 전화 처리용 Webhook URL. */
733
920
  webhookUrl?: string;
921
+ /** Webhook 호출 HTTP 메서드. */
922
+ webhookMethod?: 'POST' | 'GET';
923
+ /** Webhook 호출 시 덧붙일 헤더. 키는 'X-' 로 시작해야 한다. */
924
+ webhookHeaders?: Record<string, string>;
925
+ /** 수신(inbound) 통화 상태 통지 URL. */
926
+ statusCallback?: string;
927
+ /** 구독할 상태 이벤트(공백 구분). 미지정 시 'initiated ringing answered completed'. */
928
+ statusCallbackEvents?: string;
734
929
  }
735
930
  interface NumberUpdateParams {
736
- webhookUrl?: string;
737
- webhookMethod?: 'POST' | 'GET';
738
- /** inbound 라우팅: webhook | sip | softphone. */
739
- routingType?: 'webhook' | 'sip' | 'softphone';
740
- /** routingType='sip' 일 때 라우팅할 SipEndpoint id. */
931
+ /** 착신 라우팅 모드. */
932
+ routingType?: RoutingType;
933
+ /** routingType='agent' 필수. 같은 계정의 에이전트 id. */
934
+ agentId?: string | null;
935
+ /** routingType='callflow' 일 때 필수. 같은 계정의 콜 플로우 id. */
936
+ callFlowId?: string | null;
937
+ /** routingType='forward' 일 때 필수. 같은 계정이 보유한 번호. */
938
+ forwardTo?: string | null;
939
+ /** routingType='sip' 일 때 필수. SipEndpoint id. */
741
940
  sipEndpointId?: string | null;
742
- /** routingType='softphone' 일 때 착신할 등록 SIP credential(단말) id. */
941
+ /** routingType='softphone' 일 때 필수. 등록 단말의 SIP credential id. */
743
942
  sipCredentialId?: string | null;
943
+ /** 수신 전화 처리용 Webhook URL. */
944
+ webhookUrl?: string;
945
+ /** Webhook 호출 HTTP 메서드. */
946
+ webhookMethod?: 'POST' | 'GET';
947
+ /** Webhook 호출 시 덧붙일 헤더. */
948
+ webhookHeaders?: Record<string, string> | null;
949
+ /** routingType='agent' 에서 통화별 컨텍스트를 조회할 endpoint. */
950
+ callContextUrl?: string | null;
951
+ /** 수신(inbound) 통화 상태 통지 URL. */
952
+ statusCallback?: string | null;
953
+ /** 구독할 상태 이벤트(공백 구분). */
954
+ statusCallbackEvents?: string | null;
955
+ /** 이 번호의 통화 전사에 적용할 받아쓰기 사전 id. */
956
+ dictionaryId?: string | null;
744
957
  }
745
958
 
959
+ interface RequestOptions {
960
+ extraHeaders?: Record<string, string>;
961
+ extraQuery?: Record<string, unknown>;
962
+ timeout?: number;
963
+ }
746
964
  declare class Numbers extends APIResource {
747
- create(params?: {
748
- webhookUrl?: string;
749
- }, options?: {
750
- extraHeaders?: Record<string, string>;
751
- extraQuery?: Record<string, unknown>;
752
- timeout?: number;
753
- }): Promise<PhoneNumber>;
754
- list(options?: {
755
- extraHeaders?: Record<string, string>;
756
- extraQuery?: Record<string, unknown>;
757
- timeout?: number;
758
- }): Promise<NumberListItem[]>;
759
- update(number: string, params?: NumberUpdateParams, options?: {
760
- extraHeaders?: Record<string, string>;
761
- extraQuery?: Record<string, unknown>;
762
- timeout?: number;
763
- }): Promise<NumberUpdateResponse>;
965
+ /**
966
+ * 번호를 발급합니다. 번호 풀에서 자동으로 배정되며 어떤 번호가 나올지는 지정할 수 없습니다.
967
+ *
968
+ * 발급 직후 번호는 `routingType: "webhook"` 이고 `webhookUrl` 이 비어 있어, 그대로 두면
969
+ * 걸려온 전화가 거절됩니다. 이어서 `update()` 로 착신 라우팅을 지정하세요.
970
+ */
971
+ create(params?: NumberCreateParams, options?: RequestOptions): Promise<PhoneNumber>;
972
+ /**
973
+ * 등록된 번호 목록을 조회합니다. 페이지네이션과 필터가 없으며 보유한 번호가 한 번에 전부
974
+ * 반환됩니다.
975
+ */
976
+ list(options?: RequestOptions): Promise<NumberListItem[]>;
977
+ /**
978
+ * 번호 설정을 수정합니다. 착신 라우팅(webhook/agent/callflow/forward/sip/softphone)과
979
+ * webhook, 상태 통지, 받아쓰기 사전을 변경할 수 있습니다. 보낸 필드만 반영되고 생략한
980
+ * 필드는 유지됩니다.
981
+ *
982
+ * 라우팅을 바꾸면 다른 라우팅 필드는 서버에서 자동으로 비워집니다. `agent` 에서
983
+ * `webhook` 으로 되돌리면 `agentId` 가 null 이 되므로, 다시 `agent` 로 돌아갈 때
984
+ * `agentId` 를 새로 지정해야 합니다.
985
+ */
986
+ update(number: string, params?: NumberUpdateParams, options?: RequestOptions): Promise<NumberUpdateResponse>;
987
+ /**
988
+ * 번호를 반납합니다. 번호는 풀로 복귀하며 되돌릴 수 없습니다. 같은 번호를 다시
989
+ * 발급받는다는 보장이 없습니다.
990
+ */
764
991
  delete(number: string, options?: {
765
992
  extraHeaders?: Record<string, string>;
766
993
  timeout?: number;
@@ -989,6 +1216,7 @@ declare class AccountContext {
989
1216
  get recordings(): Recordings;
990
1217
  get webhookLogs(): WebhookLogs;
991
1218
  get assignmentLinks(): AssignmentLinks;
1219
+ get blockedRecipients(): BlockedRecipients;
992
1220
  }
993
1221
 
994
1222
  declare class ClawOpsError extends Error {
@@ -1173,6 +1401,7 @@ declare class ClawOps extends APIClient {
1173
1401
  get recordings(): Recordings;
1174
1402
  get webhookLogs(): WebhookLogs;
1175
1403
  get assignmentLinks(): AssignmentLinks;
1404
+ get blockedRecipients(): BlockedRecipients;
1176
1405
  get webhooks(): Webhooks;
1177
1406
  accounts(accountId: string): AccountContext;
1178
1407
  }
@@ -1194,4 +1423,4 @@ declare const PaginationMetaSchema: z.ZodObject<{
1194
1423
  }, z.ZodTypeAny, "passthrough">>;
1195
1424
  type PaginationMeta = z.infer<typeof PaginationMetaSchema>;
1196
1425
 
1197
- export { APIClient, type APIClientOptions, APIConnectionError, APIError, APIResponseValidationError, APIStatusError, APITimeoutError, AccountContext, AgentConnectionError, AgentError, type AssignmentLink, type AssignmentLinkAssignment, type AssignmentLinkCreateResponse, type AssignmentLinkStatus, AssignmentLinks, AuthenticationError, BadRequestError, type Call, type CallControlResponse, type CallCreateParams, type CallListParams, type CallUpdateParams, Calls, ClawOps, ClawOpsError, type ClawOpsOptions, ConflictError, InternalServerError, type Message, type MessageCreateParams, type MessageListParams, Messages, NotFoundError, type NumberCreateParams, type NumberListItem, type NumberUpdateParams, type NumberUpdateResponse, Numbers, Page, type PaginationMeta, PermissionDeniedError, type PhoneNumber, RateLimitError, type RecordingDownload, Recordings, ServiceUnavailableError, type SipCredential, SipCredentials, type SipEndpoint, SipEndpoints, UnprocessableEntityError, VERSION, type WebhookLog, WebhookLogs, WebhookVerificationError, Webhooks, ClawOps as default };
1426
+ export { APIClient, type APIClientOptions, APIConnectionError, APIError, APIResponseValidationError, APIStatusError, APITimeoutError, AccountContext, AgentConnectionError, AgentError, type AssignmentLink, type AssignmentLinkAssignment, type AssignmentLinkCreateResponse, type AssignmentLinkStatus, AssignmentLinks, AuthenticationError, BadRequestError, type BlockedChannel, type BlockedRecipient, type BlockedRecipientSource, type BlockedRecipientStatus, BlockedRecipients, type Call, type CallControlResponse, type CallCreateParams, type CallListParams, type CallUpdateParams, Calls, ClawOps, ClawOpsError, type ClawOpsOptions, ConflictError, InternalServerError, type Message, type MessageCreateParams, type MessageListParams, Messages, NotFoundError, type NumberCreateParams, type NumberListItem, type NumberUpdateParams, type NumberUpdateResponse, Numbers, Page, type PaginationMeta, PermissionDeniedError, type PhoneNumber, RateLimitError, type RecordingDownload, Recordings, type RoutingType, ServiceUnavailableError, type SipCredential, SipCredentials, type SipEndpoint, SipEndpoints, UnprocessableEntityError, VERSION, type WebhookLog, WebhookLogs, WebhookVerificationError, Webhooks, ClawOps as default };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT, VERSION, APITimeoutError, APIConnectionError, makeStatusError, APIResponseValidationError, ClawOpsError, INITIAL_RETRY_DELAY, MAX_RETRY_DELAY } from './chunk-AAU26CX6.js';
2
- export { APIConnectionError, APIError, APIResponseValidationError, APIStatusError, APITimeoutError, AgentConnectionError, AgentError, AuthenticationError, BadRequestError, ClawOpsError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, ServiceUnavailableError, UnprocessableEntityError, VERSION } from './chunk-AAU26CX6.js';
1
+ import { DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT, VERSION, APITimeoutError, APIConnectionError, makeStatusError, APIResponseValidationError, ClawOpsError, INITIAL_RETRY_DELAY, MAX_RETRY_DELAY } from './chunk-VKZ22VNA.js';
2
+ export { APIConnectionError, APIError, APIResponseValidationError, APIStatusError, APITimeoutError, AgentConnectionError, AgentError, AuthenticationError, BadRequestError, ClawOpsError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, ServiceUnavailableError, UnprocessableEntityError, VERSION } from './chunk-VKZ22VNA.js';
3
3
  import { z } from 'zod';
4
4
  import { timingSafeEqual, createHmac } from 'crypto';
5
5
 
@@ -138,9 +138,21 @@ var APIClient = class {
138
138
  const result = await this._request("PUT", path, options);
139
139
  return result;
140
140
  }
141
+ async _patch(path, options) {
142
+ const result = await this._request("PATCH", path, options);
143
+ return result;
144
+ }
141
145
  async _getRaw(path, options = {}) {
142
146
  return this._send("GET", path, options);
143
147
  }
148
+ /**
149
+ * 본문을 돌려주는 DELETE. 기존 `_delete` 는 void 라 응답을 버리는데, soft delete 처럼
150
+ * 삭제 결과 리소스를 그대로 반환하는 endpoint 가 있어서 따로 둔다.
151
+ */
152
+ async _deleteWithResponse(path, options) {
153
+ const result = await this._request("DELETE", path, options);
154
+ return result;
155
+ }
144
156
  async _delete(path, options = {}) {
145
157
  await this._request("DELETE", path, options);
146
158
  }
@@ -305,6 +317,112 @@ var AssignmentLinks = class extends APIResource {
305
317
  );
306
318
  }
307
319
  };
320
+ var BlockedRecipientSchema = z.object({
321
+ id: z.string(),
322
+ /** 국내 표기로 정규화된 번호 (예 '01012345678'). */
323
+ number: z.string(),
324
+ channel: z.enum(["call", "message"]),
325
+ /** 지금 차단 중인지. 해제분도 이력으로 조회되므로 이 값으로 구분한다. */
326
+ active: z.boolean(),
327
+ source: z.string(),
328
+ sourceRef: z.string().nullable().optional(),
329
+ note: z.string().nullable().optional(),
330
+ createdBy: z.string().nullable().optional(),
331
+ createdAt: z.string(),
332
+ updatedAt: z.string(),
333
+ unblockedAt: z.string().nullable().optional(),
334
+ unblockedSource: z.string().nullable().optional(),
335
+ unblockedBy: z.string().nullable().optional(),
336
+ unblockedNote: z.string().nullable().optional()
337
+ }).passthrough();
338
+
339
+ // src/resources/blocked-recipients.ts
340
+ var BlockedRecipients = class extends APIResource {
341
+ /**
342
+ * 번호를 수신거부 명단에 등록합니다.
343
+ *
344
+ * 하이픈·`+82` 표기 모두 허용되며 국내 표기로 정규화되어 저장됩니다.
345
+ *
346
+ * **멱등입니다** — 이미 차단 중인 (번호, 채널)을 다시 등록해도 에러가 아니라 기존 항목을
347
+ * 돌려줍니다. 같은 사람이 수신거부를 두 번 요청하는 것은 정상 상황이기 때문입니다.
348
+ */
349
+ async create(params, options = {}) {
350
+ const body = stripNotGiven({
351
+ number: params.number,
352
+ channel: params.channel,
353
+ source: params.source,
354
+ sourceRef: params.sourceRef,
355
+ note: params.note
356
+ });
357
+ return this._client._post(`${this._basePath}/blocked-recipients`, {
358
+ body,
359
+ castTo: BlockedRecipientSchema,
360
+ ...options
361
+ });
362
+ }
363
+ /**
364
+ * 수신거부 목록을 조회합니다. 기본은 **현재 차단 중인 항목만** 이며,
365
+ * 해제 이력까지 보려면 `status` 를 `'released'` 또는 `'all'` 로 지정합니다.
366
+ */
367
+ async list(params = {}, options = {}) {
368
+ const query = stripNotGiven({
369
+ channel: params.channel,
370
+ number: params.number,
371
+ status: params.status,
372
+ page: params.page,
373
+ pageSize: params.pageSize
374
+ });
375
+ const path = `${this._basePath}/blocked-recipients`;
376
+ const raw = await this._client._get(path, {
377
+ castTo: PageSchema(BlockedRecipientSchema),
378
+ query: Object.keys(query).length ? query : void 0,
379
+ ...options
380
+ });
381
+ const page = new Page(raw.data, raw.meta);
382
+ page._setClient(this._client, path, BlockedRecipientSchema, query);
383
+ return page;
384
+ }
385
+ /** 항목 상세를 조회합니다. 해제된 항목도 이력으로 남아 조회됩니다(`active: false`). */
386
+ async retrieve(blockId, options = {}) {
387
+ return this._client._get(`${this._basePath}/blocked-recipients/${blockId}`, {
388
+ castTo: BlockedRecipientSchema,
389
+ ...options
390
+ });
391
+ }
392
+ /**
393
+ * 메모를 수정합니다.
394
+ *
395
+ * 번호와 채널은 바꿀 수 없습니다 — 바꾸면 "누가 무엇을 언제 거부했는가"라는 증빙이
396
+ * 뒤틀립니다. 잘못 등록했다면 해제한 뒤 올바른 번호로 새로 등록하세요.
397
+ */
398
+ async update(blockId, params = {}, options = {}) {
399
+ return this._client._patch(`${this._basePath}/blocked-recipients/${blockId}`, {
400
+ body: { note: params.note ?? null },
401
+ castTo: BlockedRecipientSchema,
402
+ ...options
403
+ });
404
+ }
405
+ /**
406
+ * 수신거부를 해제해 다시 발신할 수 있게 합니다.
407
+ *
408
+ * **항목은 삭제되지 않습니다.** `active` 가 false 가 되고 `unblockedAt` 이 기록될 뿐,
409
+ * 행은 이력으로 남습니다 — 언제 거부했고 언제 풀렸는지가 곧 증빙이기 때문입니다.
410
+ * 해제분은 `list({ status: 'released' })` 로 볼 수 있습니다.
411
+ *
412
+ * 이미 해제된 항목에 다시 호출해도 성공하며, 최초 해제 시각은 덮어쓰지 않습니다.
413
+ */
414
+ async release(blockId, params = {}, options = {}) {
415
+ const body = stripNotGiven({ note: params.note });
416
+ return this._client._deleteWithResponse(
417
+ `${this._basePath}/blocked-recipients/${blockId}`,
418
+ {
419
+ body: Object.keys(body).length ? body : void 0,
420
+ castTo: BlockedRecipientSchema,
421
+ ...options
422
+ }
423
+ );
424
+ }
425
+ };
308
426
  var CallSchema = z.object({
309
427
  callId: z.string(),
310
428
  /**
@@ -552,25 +670,53 @@ var Messages = class extends APIResource {
552
670
  };
553
671
  var PhoneNumberSchema = z.object({
554
672
  number: z.string(),
673
+ numberType: z.string().nullable().optional(),
555
674
  source: z.string().nullable().optional(),
556
- webhookUrl: z.string().nullable().optional(),
557
- webhookMethod: z.enum(["POST", "GET"]).nullable().optional(),
558
- routingType: z.enum(["webhook", "sip", "softphone"]).nullable().optional(),
675
+ // routingType 은 enum 으로 좁히지 않는다. 좁히면 서버가 라우팅 종류를 늘렸을 때 그 번호가
676
+ // 섞인 목록 조회가 통째로 실패한다(0.28.0 까지의 실제 결함: 'agent' 로 라우팅된 번호
677
+ // 하나가 numbers.list() 전체를 깨뜨렸다).
678
+ routingType: z.string().nullable().optional(),
679
+ agentId: z.string().nullable().optional(),
680
+ callFlowId: z.string().nullable().optional(),
681
+ forwardTo: z.string().nullable().optional(),
559
682
  sipEndpointId: z.string().nullable().optional(),
560
683
  sipCredentialId: z.string().nullable().optional(),
684
+ webhookUrl: z.string().nullable().optional(),
685
+ webhookMethod: z.string().nullable().optional(),
686
+ webhookHeaders: z.record(z.string()).nullable().optional(),
687
+ callContextUrl: z.string().nullable().optional(),
688
+ statusCallback: z.string().nullable().optional(),
689
+ statusCallbackEvents: z.string().nullable().optional(),
690
+ dictionaryId: z.string().nullable().optional(),
561
691
  createdAt: z.string().nullable().optional()
562
692
  }).passthrough();
563
693
 
564
694
  // src/resources/numbers.ts
565
695
  var Numbers = class extends APIResource {
696
+ /**
697
+ * 번호를 발급합니다. 번호 풀에서 자동으로 배정되며 어떤 번호가 나올지는 지정할 수 없습니다.
698
+ *
699
+ * 발급 직후 번호는 `routingType: "webhook"` 이고 `webhookUrl` 이 비어 있어, 그대로 두면
700
+ * 걸려온 전화가 거절됩니다. 이어서 `update()` 로 착신 라우팅을 지정하세요.
701
+ */
566
702
  async create(params = {}, options = {}) {
567
- const body = stripNotGiven({ webhookUrl: params.webhookUrl });
703
+ const body = stripNotGiven({
704
+ webhookUrl: params.webhookUrl,
705
+ webhookMethod: params.webhookMethod,
706
+ webhookHeaders: params.webhookHeaders,
707
+ statusCallback: params.statusCallback,
708
+ statusCallbackEvents: params.statusCallbackEvents
709
+ });
568
710
  return this._client._post(`${this._basePath}/numbers`, {
569
711
  body: Object.keys(body).length ? body : void 0,
570
712
  castTo: PhoneNumberSchema,
571
713
  ...options
572
714
  });
573
715
  }
716
+ /**
717
+ * 등록된 번호 목록을 조회합니다. 페이지네이션과 필터가 없으며 보유한 번호가 한 번에 전부
718
+ * 반환됩니다.
719
+ */
574
720
  async list(options = {}) {
575
721
  const schema = z.object({ data: z.array(PhoneNumberSchema) }).passthrough();
576
722
  const result = await this._client._get(`${this._basePath}/numbers`, {
@@ -579,13 +725,30 @@ var Numbers = class extends APIResource {
579
725
  });
580
726
  return result.data;
581
727
  }
728
+ /**
729
+ * 번호 설정을 수정합니다. 착신 라우팅(webhook/agent/callflow/forward/sip/softphone)과
730
+ * webhook, 상태 통지, 받아쓰기 사전을 변경할 수 있습니다. 보낸 필드만 반영되고 생략한
731
+ * 필드는 유지됩니다.
732
+ *
733
+ * 라우팅을 바꾸면 다른 라우팅 필드는 서버에서 자동으로 비워집니다. `agent` 에서
734
+ * `webhook` 으로 되돌리면 `agentId` 가 null 이 되므로, 다시 `agent` 로 돌아갈 때
735
+ * `agentId` 를 새로 지정해야 합니다.
736
+ */
582
737
  async update(number, params = {}, options = {}) {
583
738
  const body = stripNotGiven({
584
- webhookUrl: params.webhookUrl,
585
- webhookMethod: params.webhookMethod,
586
739
  routingType: params.routingType,
740
+ agentId: params.agentId,
741
+ callFlowId: params.callFlowId,
742
+ forwardTo: params.forwardTo,
587
743
  sipEndpointId: params.sipEndpointId,
588
- sipCredentialId: params.sipCredentialId
744
+ sipCredentialId: params.sipCredentialId,
745
+ webhookUrl: params.webhookUrl,
746
+ webhookMethod: params.webhookMethod,
747
+ webhookHeaders: params.webhookHeaders,
748
+ callContextUrl: params.callContextUrl,
749
+ statusCallback: params.statusCallback,
750
+ statusCallbackEvents: params.statusCallbackEvents,
751
+ dictionaryId: params.dictionaryId
589
752
  });
590
753
  return this._client._put(`${this._basePath}/numbers/${number}`, {
591
754
  body,
@@ -593,6 +756,10 @@ var Numbers = class extends APIResource {
593
756
  ...options
594
757
  });
595
758
  }
759
+ /**
760
+ * 번호를 반납합니다. 번호는 풀로 복귀하며 되돌릴 수 없습니다. 같은 번호를 다시
761
+ * 발급받는다는 보장이 없습니다.
762
+ */
596
763
  async delete(number, options = {}) {
597
764
  await this._client._delete(`${this._basePath}/numbers/${number}`, options);
598
765
  }
@@ -773,6 +940,9 @@ var AccountContext = class {
773
940
  get assignmentLinks() {
774
941
  return new AssignmentLinks(this._client, this._accountId);
775
942
  }
943
+ get blockedRecipients() {
944
+ return new BlockedRecipients(this._client, this._accountId);
945
+ }
776
946
  };
777
947
  var WebhookVerificationError = class extends ClawOpsError {
778
948
  constructor(message = "Webhook \uC11C\uBA85\uC774 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.") {
@@ -845,6 +1015,9 @@ var ClawOps = class extends APIClient {
845
1015
  get assignmentLinks() {
846
1016
  return new AssignmentLinks(this, this._defaultAccountId);
847
1017
  }
1018
+ get blockedRecipients() {
1019
+ return new BlockedRecipients(this, this._defaultAccountId);
1020
+ }
848
1021
  get webhooks() {
849
1022
  return new Webhooks();
850
1023
  }
@@ -856,6 +1029,6 @@ var ClawOps = class extends APIClient {
856
1029
  // src/client-default.ts
857
1030
  var client_default_default = ClawOps;
858
1031
 
859
- export { APIClient, AccountContext, AssignmentLinks, Calls, ClawOps, Messages, Numbers, Page, Recordings, SipCredentials, SipEndpoints, WebhookLogs, WebhookVerificationError, Webhooks, client_default_default as default };
1032
+ export { APIClient, AccountContext, AssignmentLinks, BlockedRecipients, Calls, ClawOps, Messages, Numbers, Page, Recordings, SipCredentials, SipEndpoints, WebhookLogs, WebhookVerificationError, Webhooks, client_default_default as default };
860
1033
  //# sourceMappingURL=index.js.map
861
1034
  //# sourceMappingURL=index.js.map