@teamlearners/clawops 0.27.0 → 0.28.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$1 = {
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$1): 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$1): Promise<Page<AssignmentLink>>;
255
+ retrieve(linkId: string, options?: RequestOptions$1): 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 = {
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): 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): Promise<Page<BlockedRecipient>>;
360
+ /** 항목 상세를 조회합니다. 해제된 항목도 이력으로 남아 조회됩니다(`active: false`). */
361
+ retrieve(blockId: string, options?: RequestOptions): Promise<BlockedRecipient>;
362
+ /**
363
+ * 메모를 수정합니다.
364
+ *
365
+ * 번호와 채널은 바꿀 수 없습니다 — 바꾸면 "누가 무엇을 언제 거부했는가"라는 증빙이
366
+ * 뒤틀립니다. 잘못 등록했다면 해제한 뒤 올바른 번호로 새로 등록하세요.
367
+ */
368
+ update(blockId: string, params?: {
369
+ note?: string | null;
370
+ }, options?: RequestOptions): 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): Promise<BlockedRecipient>;
383
+ }
384
+
244
385
  declare const CallSchema: z.ZodObject<{
245
386
  callId: z.ZodString;
246
387
  /**
@@ -989,6 +1130,7 @@ declare class AccountContext {
989
1130
  get recordings(): Recordings;
990
1131
  get webhookLogs(): WebhookLogs;
991
1132
  get assignmentLinks(): AssignmentLinks;
1133
+ get blockedRecipients(): BlockedRecipients;
992
1134
  }
993
1135
 
994
1136
  declare class ClawOpsError extends Error {
@@ -1173,6 +1315,7 @@ declare class ClawOps extends APIClient {
1173
1315
  get recordings(): Recordings;
1174
1316
  get webhookLogs(): WebhookLogs;
1175
1317
  get assignmentLinks(): AssignmentLinks;
1318
+ get blockedRecipients(): BlockedRecipients;
1176
1319
  get webhooks(): Webhooks;
1177
1320
  accounts(accountId: string): AccountContext;
1178
1321
  }
@@ -1194,4 +1337,4 @@ declare const PaginationMetaSchema: z.ZodObject<{
1194
1337
  }, z.ZodTypeAny, "passthrough">>;
1195
1338
  type PaginationMeta = z.infer<typeof PaginationMetaSchema>;
1196
1339
 
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 };
1340
+ 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, 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-5MCVFEXW.js';
2
+ export { APIConnectionError, APIError, APIResponseValidationError, APIStatusError, APITimeoutError, AgentConnectionError, AgentError, AuthenticationError, BadRequestError, ClawOpsError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, ServiceUnavailableError, UnprocessableEntityError, VERSION } from './chunk-5MCVFEXW.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
  /**
@@ -773,6 +891,9 @@ var AccountContext = class {
773
891
  get assignmentLinks() {
774
892
  return new AssignmentLinks(this._client, this._accountId);
775
893
  }
894
+ get blockedRecipients() {
895
+ return new BlockedRecipients(this._client, this._accountId);
896
+ }
776
897
  };
777
898
  var WebhookVerificationError = class extends ClawOpsError {
778
899
  constructor(message = "Webhook \uC11C\uBA85\uC774 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.") {
@@ -845,6 +966,9 @@ var ClawOps = class extends APIClient {
845
966
  get assignmentLinks() {
846
967
  return new AssignmentLinks(this, this._defaultAccountId);
847
968
  }
969
+ get blockedRecipients() {
970
+ return new BlockedRecipients(this, this._defaultAccountId);
971
+ }
848
972
  get webhooks() {
849
973
  return new Webhooks();
850
974
  }
@@ -856,6 +980,6 @@ var ClawOps = class extends APIClient {
856
980
  // src/client-default.ts
857
981
  var client_default_default = ClawOps;
858
982
 
859
- export { APIClient, AccountContext, AssignmentLinks, Calls, ClawOps, Messages, Numbers, Page, Recordings, SipCredentials, SipEndpoints, WebhookLogs, WebhookVerificationError, Webhooks, client_default_default as default };
983
+ export { APIClient, AccountContext, AssignmentLinks, BlockedRecipients, Calls, ClawOps, Messages, Numbers, Page, Recordings, SipCredentials, SipEndpoints, WebhookLogs, WebhookVerificationError, Webhooks, client_default_default as default };
860
984
  //# sourceMappingURL=index.js.map
861
985
  //# sourceMappingURL=index.js.map