@teamlearners/clawops 0.34.0 → 0.36.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 +145 -9
- package/dist/agent/index.cjs +10 -10
- package/dist/agent/index.js +2 -2
- package/dist/{chunk-TVDUOKJD.cjs → chunk-IYSPOOKH.cjs} +14 -2
- package/dist/chunk-IYSPOOKH.cjs.map +1 -0
- package/dist/{chunk-2IHVQDIP.cjs → chunk-LKFNV2GI.cjs} +3 -3
- package/dist/{chunk-2IHVQDIP.cjs.map → chunk-LKFNV2GI.cjs.map} +1 -1
- package/dist/{chunk-36JABW7P.js → chunk-VYGIWHRU.js} +14 -2
- package/dist/chunk-VYGIWHRU.js.map +1 -0
- package/dist/{chunk-QNWXGJTJ.js → chunk-XL2VWU36.js} +3 -3
- package/dist/{chunk-QNWXGJTJ.js.map → chunk-XL2VWU36.js.map} +1 -1
- package/dist/{client-CKaAfPlF.d.cts → client-DKsEma11.d.cts} +580 -21
- package/dist/{client-CKaAfPlF.d.ts → client-DKsEma11.d.ts} +580 -21
- package/dist/index.cjs +307 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +272 -7
- package/dist/index.js.map +1 -1
- package/dist/solapi/index.cjs +33 -11
- package/dist/solapi/index.cjs.map +1 -1
- package/dist/solapi/index.d.cts +23 -10
- package/dist/solapi/index.d.ts +23 -10
- package/dist/solapi/index.js +28 -6
- package/dist/solapi/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-36JABW7P.js.map +0 -1
- package/dist/chunk-TVDUOKJD.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var chunkLKFNV2GI_cjs = require('./chunk-LKFNV2GI.cjs');
|
|
6
|
+
var chunkIYSPOOKH_cjs = require('./chunk-IYSPOOKH.cjs');
|
|
7
7
|
var zod = require('zod');
|
|
8
8
|
var crypto = require('crypto');
|
|
9
9
|
|
|
@@ -14,11 +14,11 @@ function validateBaseUrl(url) {
|
|
|
14
14
|
try {
|
|
15
15
|
parsed = new URL(url);
|
|
16
16
|
} catch {
|
|
17
|
-
throw new
|
|
17
|
+
throw new chunkIYSPOOKH_cjs.ClawOpsError(`Invalid base_url: ${url}`);
|
|
18
18
|
}
|
|
19
19
|
if (parsed.protocol === "https:") return url;
|
|
20
20
|
if (parsed.protocol === "http:" && LOCALHOST_HOSTS.has(parsed.hostname)) return url;
|
|
21
|
-
throw new
|
|
21
|
+
throw new chunkIYSPOOKH_cjs.ClawOpsError(
|
|
22
22
|
`base_url\uC740 HTTPS\uB97C \uC0AC\uC6A9\uD574\uC57C \uD569\uB2C8\uB2E4 (\uBC1B\uC740 \uAC12: '${url}'). \uB85C\uCEEC \uAC1C\uBC1C \uC2DC\uC5D0\uB294 http://localhost\uB97C \uC0AC\uC6A9\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`
|
|
23
23
|
);
|
|
24
24
|
}
|
|
@@ -31,9 +31,9 @@ var APIClient = class {
|
|
|
31
31
|
_defaultHeaders;
|
|
32
32
|
constructor(options) {
|
|
33
33
|
this._apiKey = options.apiKey;
|
|
34
|
-
this._baseURL = validateBaseUrl((options.baseURL ??
|
|
35
|
-
this._maxRetries = options.maxRetries ??
|
|
36
|
-
this._timeout = options.timeout ??
|
|
34
|
+
this._baseURL = validateBaseUrl((options.baseURL ?? chunkLKFNV2GI_cjs.DEFAULT_BASE_URL).replace(/\/+$/, ""));
|
|
35
|
+
this._maxRetries = options.maxRetries ?? chunkLKFNV2GI_cjs.DEFAULT_MAX_RETRIES;
|
|
36
|
+
this._timeout = options.timeout ?? chunkLKFNV2GI_cjs.DEFAULT_TIMEOUT;
|
|
37
37
|
this._fetch = options.fetch ?? globalThis.fetch;
|
|
38
38
|
this._defaultHeaders = options.defaultHeaders ?? {};
|
|
39
39
|
}
|
|
@@ -42,7 +42,7 @@ var APIClient = class {
|
|
|
42
42
|
Authorization: `Bearer ${this._apiKey}`,
|
|
43
43
|
"Content-Type": "application/json",
|
|
44
44
|
Accept: "application/json",
|
|
45
|
-
"User-Agent": `claw-ops-node/${
|
|
45
|
+
"User-Agent": `claw-ops-node/${chunkLKFNV2GI_cjs.VERSION}`,
|
|
46
46
|
...this._defaultHeaders
|
|
47
47
|
};
|
|
48
48
|
if (extra) Object.assign(headers, extra);
|
|
@@ -78,14 +78,14 @@ var APIClient = class {
|
|
|
78
78
|
await this._sleep(this._retryDelay(this._maxRetries - retriesLeft));
|
|
79
79
|
continue;
|
|
80
80
|
}
|
|
81
|
-
throw new
|
|
81
|
+
throw new chunkIYSPOOKH_cjs.APITimeoutError({ method: method2, url });
|
|
82
82
|
}
|
|
83
83
|
if (retriesLeft > 0) {
|
|
84
84
|
retriesLeft--;
|
|
85
85
|
await this._sleep(this._retryDelay(this._maxRetries - retriesLeft));
|
|
86
86
|
continue;
|
|
87
87
|
}
|
|
88
|
-
throw new
|
|
88
|
+
throw new chunkIYSPOOKH_cjs.APIConnectionError({ method: method2, url });
|
|
89
89
|
} finally {
|
|
90
90
|
clearTimeout(timeoutId);
|
|
91
91
|
}
|
|
@@ -101,7 +101,7 @@ var APIClient = class {
|
|
|
101
101
|
} catch {
|
|
102
102
|
body = null;
|
|
103
103
|
}
|
|
104
|
-
throw
|
|
104
|
+
throw chunkIYSPOOKH_cjs.makeStatusError(response.status, body, response.headers, { method: method2, url });
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
async _request(method2, path, options = {}) {
|
|
@@ -112,11 +112,11 @@ var APIClient = class {
|
|
|
112
112
|
try {
|
|
113
113
|
json = await response.json();
|
|
114
114
|
} catch {
|
|
115
|
-
throw new
|
|
115
|
+
throw new chunkIYSPOOKH_cjs.APIResponseValidationError({ status: response.status }, { method: method2, url });
|
|
116
116
|
}
|
|
117
117
|
const parsed = options.castTo.safeParse(json);
|
|
118
118
|
if (!parsed.success) {
|
|
119
|
-
throw new
|
|
119
|
+
throw new chunkIYSPOOKH_cjs.APIResponseValidationError({ status: response.status }, { method: method2, url });
|
|
120
120
|
}
|
|
121
121
|
return parsed.data;
|
|
122
122
|
}
|
|
@@ -124,7 +124,7 @@ var APIClient = class {
|
|
|
124
124
|
return status === 408 || status === 409 || status === 429 || status >= 500;
|
|
125
125
|
}
|
|
126
126
|
_retryDelay(retriesTaken) {
|
|
127
|
-
const delay = Math.min(
|
|
127
|
+
const delay = Math.min(chunkLKFNV2GI_cjs.INITIAL_RETRY_DELAY * 2 ** retriesTaken, chunkLKFNV2GI_cjs.MAX_RETRY_DELAY);
|
|
128
128
|
return delay * (1 + Math.random());
|
|
129
129
|
}
|
|
130
130
|
_sleep(ms) {
|
|
@@ -624,10 +624,236 @@ var Calls = class extends APIResource {
|
|
|
624
624
|
});
|
|
625
625
|
}
|
|
626
626
|
};
|
|
627
|
+
var KakaoChannelSchema = zod.z.object({
|
|
628
|
+
/** ClawOps 채널 리소스 ID. 템플릿 조회와 알림톡 발송에 이 값을 쓴다. */
|
|
629
|
+
id: zod.z.string(),
|
|
630
|
+
/** 카카오 채널 검색용 ID. `@` 없는 형태로 저장된다. */
|
|
631
|
+
searchId: zod.z.string(),
|
|
632
|
+
name: zod.z.string(),
|
|
633
|
+
categoryCode: zod.z.string(),
|
|
634
|
+
/**
|
|
635
|
+
* `connected` = 연결 완료. `needs_attention` = 연결 기록은 있으나 카카오 채널 상태를
|
|
636
|
+
* 확인하지 못한 상태다 — 실제로 끊겼을 수도, 일시적인 조회 실패일 수도 있다.
|
|
637
|
+
* `channels.retrieve()` 를 다시 부르면 재확인한다.
|
|
638
|
+
*
|
|
639
|
+
* ⛔ **닫힌 enum 으로 두지 않는다.** 어휘는 서버가 소유하므로, 상태가 하나 늘면
|
|
640
|
+
* 닫힌 enum 은 조회를 통째로 실패시킨다(알림톡 `'ata'` 가 정확히 그렇게 터졌다).
|
|
641
|
+
* 열린 유니온이면 자동완성만 낡고 조회는 계속 산다.
|
|
642
|
+
*/
|
|
643
|
+
status: zod.z.string(),
|
|
644
|
+
/** 담당자 휴대전화번호(마스킹). 원문은 저장하지 않는다. */
|
|
645
|
+
managerPhoneMasked: zod.z.string().nullable().optional(),
|
|
646
|
+
connectedAt: zod.z.string(),
|
|
647
|
+
/** 카카오 채널 상태를 마지막으로 확인한 시각. null 이면 연결 이후 한 번도 확인하지 않았다. */
|
|
648
|
+
syncedAt: zod.z.string().nullable().optional(),
|
|
649
|
+
createdAt: zod.z.string(),
|
|
650
|
+
updatedAt: zod.z.string()
|
|
651
|
+
}).passthrough();
|
|
652
|
+
var KakaoTemplateSchema = zod.z.object({
|
|
653
|
+
/** ClawOps 템플릿 리소스 ID. 발송의 `kakao.templateId` 에 이 값을 쓴다. */
|
|
654
|
+
id: zod.z.string(),
|
|
655
|
+
/** ClawOps 채널 리소스 ID. 발송의 `kakao.channelId` 와 같은 값이다. */
|
|
656
|
+
channelId: zod.z.string(),
|
|
657
|
+
name: zod.z.string(),
|
|
658
|
+
/** 검수를 받은 템플릿 본문. `#{변수}` 자리는 발송 시 치환된다. */
|
|
659
|
+
content: zod.z.string(),
|
|
660
|
+
/**
|
|
661
|
+
* 카카오 검수 상태(`APPROVED`·`REJECTED` 등). **카카오 쪽 열린 집합이라 문자열이다.**
|
|
662
|
+
* 발송 가능 여부 판정은 `sendable` 이 정본이다.
|
|
663
|
+
*/
|
|
664
|
+
status: zod.z.string(),
|
|
665
|
+
/** 휴면 템플릿. `true` 면 승인 상태여도 발송할 수 없다. */
|
|
666
|
+
dormant: zod.z.boolean(),
|
|
667
|
+
/** 지금 발송에 쓸 수 있으면 true. `status === 'APPROVED' && !dormant` 다. */
|
|
668
|
+
sendable: zod.z.boolean(),
|
|
669
|
+
/** `CHANNEL`(채널 소유) 또는 `GROUP`(기본 제공). */
|
|
670
|
+
assignType: zod.z.string(),
|
|
671
|
+
messageType: zod.z.string(),
|
|
672
|
+
emphasizeType: zod.z.string(),
|
|
673
|
+
/**
|
|
674
|
+
* 발송 시 `kakao.variables` 에 모두 채워야 하는 변수 이름.
|
|
675
|
+
* 버튼 링크·강조 문구에 들어간 변수도 이 한 목록에 모인다.
|
|
676
|
+
*/
|
|
677
|
+
variables: zod.z.array(zod.z.string()),
|
|
678
|
+
createdAt: zod.z.string(),
|
|
679
|
+
updatedAt: zod.z.string()
|
|
680
|
+
}).passthrough();
|
|
681
|
+
var KakaoChannelCategorySchema = zod.z.object({
|
|
682
|
+
/** 채널 연결의 `categoryCode` 에 그대로 보내는 값. */
|
|
683
|
+
code: zod.z.string(),
|
|
684
|
+
name: zod.z.string()
|
|
685
|
+
}).passthrough();
|
|
686
|
+
var KakaoChannelCategoryListSchema = zod.z.object({
|
|
687
|
+
data: zod.z.array(KakaoChannelCategorySchema),
|
|
688
|
+
meta: zod.z.object({
|
|
689
|
+
/** 이 목록을 공급자에서 실제로 받아 온 시각. */
|
|
690
|
+
fetchedAt: zod.z.string(),
|
|
691
|
+
/** 서버 캐시에서 응답했는지. 캐시는 짧고 값이 바뀌면 자동으로 따라간다. */
|
|
692
|
+
cached: zod.z.boolean()
|
|
693
|
+
}).passthrough()
|
|
694
|
+
}).passthrough();
|
|
695
|
+
var KakaoTokenRequestSchema = zod.z.object({
|
|
696
|
+
requested: zod.z.boolean(),
|
|
697
|
+
/** 정규화된 검색용 ID. `channels.connect()` 에 이 값을 그대로 보낸다. */
|
|
698
|
+
searchId: zod.z.string(),
|
|
699
|
+
/** 인증번호가 발송된 번호(마스킹). */
|
|
700
|
+
phoneNumberMasked: zod.z.string(),
|
|
701
|
+
/** 재요청까지 기다릴 시간(초). */
|
|
702
|
+
retryAfterSeconds: zod.z.number()
|
|
703
|
+
}).passthrough();
|
|
704
|
+
|
|
705
|
+
// src/resources/kakao.ts
|
|
706
|
+
var KakaoChannels = class extends APIResource {
|
|
707
|
+
get _path() {
|
|
708
|
+
return `${this._basePath}/kakao/channels`;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* 연결된 채널 목록.
|
|
712
|
+
*
|
|
713
|
+
* **카카오 쪽 상태를 확인하지 않는다** — 저장된 연결 정보를 그대로 돌려주므로 빠르다.
|
|
714
|
+
* 실제 채널 상태까지 확인하려면 `retrieve()` 를 쓴다.
|
|
715
|
+
*/
|
|
716
|
+
async list(params = {}, options = {}) {
|
|
717
|
+
const query = stripNotGiven({
|
|
718
|
+
status: params.status,
|
|
719
|
+
page: params.page,
|
|
720
|
+
pageSize: params.pageSize
|
|
721
|
+
});
|
|
722
|
+
const path = this._path;
|
|
723
|
+
const raw = await this._client._get(path, {
|
|
724
|
+
castTo: PageSchema(KakaoChannelSchema),
|
|
725
|
+
query: Object.keys(query).length ? query : void 0,
|
|
726
|
+
...options
|
|
727
|
+
});
|
|
728
|
+
const page = new Page(raw.data, raw.meta);
|
|
729
|
+
page._setClient(this._client, path, KakaoChannelSchema, query);
|
|
730
|
+
return page;
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* 채널 하나를 조회한다. **목록과 달리 카카오 쪽 상태를 실제로 확인하고 `status` 를 갱신한다.**
|
|
734
|
+
*
|
|
735
|
+
* `connect()` 가 타임아웃됐을 때 결과를 확정하는 경로이기도 하다 — 연결을 재호출하면 중복
|
|
736
|
+
* 등록을 시도하게 되지만 이 조회는 몇 번을 불러도 안전하다.
|
|
737
|
+
*
|
|
738
|
+
* 카카오 쪽 조회에 실패해도 `404` 가 아니다. 연결 기록은 유효하므로 `status` 가
|
|
739
|
+
* `needs_attention` 으로 온다.
|
|
740
|
+
*/
|
|
741
|
+
async retrieve(channelId, options = {}) {
|
|
742
|
+
return this._client._get(`${this._path}/${channelId}`, {
|
|
743
|
+
castTo: KakaoChannelSchema,
|
|
744
|
+
...options
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* 채널 권한을 증명할 인증번호를 **담당자 휴대전화로 발송**해 달라고 요청한다. 연결의 첫 단계다.
|
|
749
|
+
*
|
|
750
|
+
* 응답에 인증번호는 없다(`202`). 받은 번호는 `connect()` 의 `token` 으로 보내며, 유효 시간이
|
|
751
|
+
* 있으므로 받은 뒤 바로 진행한다. 재요청이 잦으면 `429 KAKAO_RATE_LIMITED` 이고
|
|
752
|
+
* 응답의 `retryAfterSeconds` 만큼 기다린다.
|
|
753
|
+
*/
|
|
754
|
+
async requestToken(params, options = {}) {
|
|
755
|
+
return this._client._post(`${this._path}/token`, {
|
|
756
|
+
body: { searchId: params.searchId, phoneNumber: params.phoneNumber },
|
|
757
|
+
castTo: KakaoTokenRequestSchema,
|
|
758
|
+
...options
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* 인증번호로 채널 연결을 완료한다. **먼저 `requestToken()` 을 불러야 한다.**
|
|
763
|
+
*
|
|
764
|
+
* **멱등이다** — 이미 이 계정에 연결된 채널이면 인증번호를 소모하지 않고 기존 연결을 돌려준다.
|
|
765
|
+
* 다른 계정에 연결된 채널은 멱등이 아니라 충돌이라 `409 KAKAO_CHANNEL_ALREADY_LINKED` 다.
|
|
766
|
+
*
|
|
767
|
+
* ⚠️ **타임아웃되면 재호출하지 말 것.** 이미 연결에 성공했을 수 있어 중복 등록을 시도하게 된다.
|
|
768
|
+
* `list()` 나 `retrieve()` 로 실제 등록 여부를 확인한 뒤 결과를 확정한다.
|
|
769
|
+
*
|
|
770
|
+
* ⚠️ **실패해도 인증번호는 소모된다**(`422 KAKAO_TOKEN_INVALID`·`KAKAO_CHANNEL_REJECTED`).
|
|
771
|
+
* 원인을 해결한 뒤 `requestToken()` 부터 다시 시작해야 한다.
|
|
772
|
+
*/
|
|
773
|
+
async connect(params, options = {}) {
|
|
774
|
+
return this._client._post(this._path, {
|
|
775
|
+
body: {
|
|
776
|
+
searchId: params.searchId,
|
|
777
|
+
phoneNumber: params.phoneNumber,
|
|
778
|
+
categoryCode: params.categoryCode,
|
|
779
|
+
token: params.token
|
|
780
|
+
},
|
|
781
|
+
castTo: KakaoChannelSchema,
|
|
782
|
+
...options
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* 채널 연동을 해제한다. 카카오톡 채널 자체는 지워지지 않고 ClawOps 와의 연동만 끊긴다.
|
|
787
|
+
*
|
|
788
|
+
* ⚠️ **되돌릴 수 없고, 그 채널에 등록된 알림톡 템플릿도 함께 삭제된다.** 템플릿은 카카오
|
|
789
|
+
* 검수를 다시 받아야 하므로 복구에 시간이 걸린다 — 호출 전에 사용자 확인을 받을 것.
|
|
790
|
+
*
|
|
791
|
+
* 해제 후에는 그 채널을 다시 연결할 수 있다(본인이든 다른 계정이든). `requestToken()` 부터
|
|
792
|
+
* 다시 시작하면 된다.
|
|
793
|
+
*/
|
|
794
|
+
async disconnect(channelId, options = {}) {
|
|
795
|
+
return this._client._deleteWithResponse(`${this._path}/${channelId}`, {
|
|
796
|
+
castTo: KakaoChannelSchema,
|
|
797
|
+
...options
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
var KakaoTemplates = class extends APIResource {
|
|
802
|
+
/**
|
|
803
|
+
* 한 채널의 알림톡 템플릿 목록.
|
|
804
|
+
*
|
|
805
|
+
* 응답의 `data[].id` 를 발송의 `kakao.templateId` 로, `data[].channelId` 를
|
|
806
|
+
* `kakao.channelId` 로 쓴다. **`sendable: true` 인 템플릿만 발송할 수 있고**,
|
|
807
|
+
* `variables` 의 모든 항목을 발송 요청의 `kakao.variables` 에 채워야 한다.
|
|
808
|
+
*/
|
|
809
|
+
async list(params, options = {}) {
|
|
810
|
+
const query = stripNotGiven({
|
|
811
|
+
channelId: params.channelId,
|
|
812
|
+
page: params.page,
|
|
813
|
+
pageSize: params.pageSize
|
|
814
|
+
});
|
|
815
|
+
const path = `${this._basePath}/kakao/templates`;
|
|
816
|
+
const raw = await this._client._get(path, {
|
|
817
|
+
castTo: PageSchema(KakaoTemplateSchema),
|
|
818
|
+
query: Object.keys(query).length ? query : void 0,
|
|
819
|
+
...options
|
|
820
|
+
});
|
|
821
|
+
const page = new Page(raw.data, raw.meta);
|
|
822
|
+
page._setClient(this._client, path, KakaoTemplateSchema, query);
|
|
823
|
+
return page;
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
var Kakao = class extends APIResource {
|
|
827
|
+
get channels() {
|
|
828
|
+
return new KakaoChannels(this._client, this._accountId);
|
|
829
|
+
}
|
|
830
|
+
get templates() {
|
|
831
|
+
return new KakaoTemplates(this._client, this._accountId);
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* 채널 연결 시 지정할 업종 카테고리 목록.
|
|
835
|
+
*
|
|
836
|
+
* **값을 코드에 하드코딩하지 말 것** — 카카오/공급자 쪽에서 늘거나 바뀌는 열린 집합이고
|
|
837
|
+
* 이 응답이 그때그때의 정본이다. 응답의 `code` 를 `channels.connect()` 의 `categoryCode`
|
|
838
|
+
* 로 그대로 보낸다.
|
|
839
|
+
*
|
|
840
|
+
* 페이지네이션이 없어 `Page` 가 아니라 `{ data, meta }` 를 그대로 돌려준다.
|
|
841
|
+
*/
|
|
842
|
+
async channelCategories(options = {}) {
|
|
843
|
+
return this._client._get(`${this._basePath}/kakao/channel-categories`, {
|
|
844
|
+
castTo: KakaoChannelCategoryListSchema,
|
|
845
|
+
...options
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
};
|
|
627
849
|
var MessageSchema = zod.z.object({
|
|
628
850
|
messageId: zod.z.string(),
|
|
629
851
|
status: zod.z.enum(["queued", "sending", "sent", "failed", "received"]),
|
|
630
|
-
|
|
852
|
+
/**
|
|
853
|
+
* `'ata'` 는 카카오 알림톡이다. `body` 에는 템플릿에 변수를 치환한 결과가 담기고,
|
|
854
|
+
* 버튼·아이템 리스트·강조 문구는 템플릿에 검수된 대로 발송되어 이 값에는 담기지 않는다.
|
|
855
|
+
*/
|
|
856
|
+
type: zod.z.enum(["sms", "lms", "mms", "rcs", "ata"]),
|
|
631
857
|
to: zod.z.string(),
|
|
632
858
|
from: zod.z.string(),
|
|
633
859
|
body: zod.z.string().nullable().optional(),
|
|
@@ -642,6 +868,25 @@ var MessageSchema = zod.z.object({
|
|
|
642
868
|
|
|
643
869
|
// src/resources/messages.ts
|
|
644
870
|
var Messages = class extends APIResource {
|
|
871
|
+
/**
|
|
872
|
+
* 문자(SMS/LMS/MMS) 또는 카카오 알림톡을 발송합니다.
|
|
873
|
+
*
|
|
874
|
+
* 둘은 배타적입니다 — `kakao` 를 실으면 알림톡이고, 이때 `body`·`subject`·`mediaUrl` 은
|
|
875
|
+
* 실을 수 없습니다(본문은 검수된 템플릿이 정합니다).
|
|
876
|
+
*
|
|
877
|
+
* ```ts
|
|
878
|
+
* // 문자
|
|
879
|
+
* await client.messages.create({ to: '010…', from: '070…', body: '안녕하세요' });
|
|
880
|
+
*
|
|
881
|
+
* // 알림톡 — 실패하면 fallback 문구가 문자로 대신 나갑니다(별도 1건으로 과금)
|
|
882
|
+
* await client.messages.create({
|
|
883
|
+
* to: '010…',
|
|
884
|
+
* from: '070…',
|
|
885
|
+
* kakao: { channelId, templateId, variables: { 고객명: '홍길동' } },
|
|
886
|
+
* fallback: { body: '주문이 접수되었습니다.' },
|
|
887
|
+
* });
|
|
888
|
+
* ```
|
|
889
|
+
*/
|
|
645
890
|
async create(params, options = {}) {
|
|
646
891
|
const body = stripNotGiven({
|
|
647
892
|
To: params.to,
|
|
@@ -650,7 +895,19 @@ var Messages = class extends APIResource {
|
|
|
650
895
|
Type: params.type,
|
|
651
896
|
Subject: params.subject,
|
|
652
897
|
MediaUrl: params.mediaUrl,
|
|
653
|
-
IdempotencyKey: params.idempotencyKey
|
|
898
|
+
IdempotencyKey: params.idempotencyKey,
|
|
899
|
+
// 중첩 객체는 손으로 조립한다 — stripNotGiven 은 한 겹만 훑는다.
|
|
900
|
+
Kakao: params.kakao && stripNotGiven({
|
|
901
|
+
ChannelId: params.kakao.channelId,
|
|
902
|
+
TemplateId: params.kakao.templateId,
|
|
903
|
+
Variables: params.kakao.variables
|
|
904
|
+
}),
|
|
905
|
+
Fallback: params.fallback && stripNotGiven({
|
|
906
|
+
Type: params.fallback.type,
|
|
907
|
+
Subject: params.fallback.subject,
|
|
908
|
+
Body: params.fallback.body,
|
|
909
|
+
Disabled: params.fallback.disabled
|
|
910
|
+
})
|
|
654
911
|
});
|
|
655
912
|
return this._client._post(`${this._basePath}/messages`, {
|
|
656
913
|
body,
|
|
@@ -662,6 +919,7 @@ var Messages = class extends APIResource {
|
|
|
662
919
|
const query = stripNotGiven({
|
|
663
920
|
type: params.type,
|
|
664
921
|
status: params.status,
|
|
922
|
+
number: params.number,
|
|
665
923
|
page: params.page,
|
|
666
924
|
pageSize: params.pageSize
|
|
667
925
|
});
|
|
@@ -958,8 +1216,11 @@ var AccountContext = class {
|
|
|
958
1216
|
get blockedRecipients() {
|
|
959
1217
|
return new BlockedRecipients(this._client, this._accountId);
|
|
960
1218
|
}
|
|
1219
|
+
get kakao() {
|
|
1220
|
+
return new Kakao(this._client, this._accountId);
|
|
1221
|
+
}
|
|
961
1222
|
};
|
|
962
|
-
var WebhookVerificationError = class extends
|
|
1223
|
+
var WebhookVerificationError = class extends chunkIYSPOOKH_cjs.ClawOpsError {
|
|
963
1224
|
constructor(message = "Webhook \uC11C\uBA85\uC774 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.") {
|
|
964
1225
|
super(message);
|
|
965
1226
|
this.name = "WebhookVerificationError";
|
|
@@ -989,13 +1250,13 @@ var ClawOps = class extends APIClient {
|
|
|
989
1250
|
constructor(options = {}) {
|
|
990
1251
|
let apiKey = options.apiKey ?? process.env.CLAWOPS_API_KEY;
|
|
991
1252
|
if (!apiKey) {
|
|
992
|
-
throw new
|
|
1253
|
+
throw new chunkIYSPOOKH_cjs.ClawOpsError("apiKey\uB97C \uC9C0\uC815\uD558\uAC70\uB098 CLAWOPS_API_KEY \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694.");
|
|
993
1254
|
}
|
|
994
1255
|
let accountId = options.accountId ?? process.env.CLAWOPS_ACCOUNT_ID;
|
|
995
1256
|
if (!accountId) {
|
|
996
|
-
throw new
|
|
1257
|
+
throw new chunkIYSPOOKH_cjs.ClawOpsError("accountId\uB97C \uC9C0\uC815\uD558\uAC70\uB098 CLAWOPS_ACCOUNT_ID \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694.");
|
|
997
1258
|
}
|
|
998
|
-
const baseURL = options.baseURL ?? process.env.CLAWOPS_BASE_URL ??
|
|
1259
|
+
const baseURL = options.baseURL ?? process.env.CLAWOPS_BASE_URL ?? chunkLKFNV2GI_cjs.DEFAULT_BASE_URL;
|
|
999
1260
|
super({
|
|
1000
1261
|
apiKey,
|
|
1001
1262
|
baseURL,
|
|
@@ -1033,6 +1294,10 @@ var ClawOps = class extends APIClient {
|
|
|
1033
1294
|
get blockedRecipients() {
|
|
1034
1295
|
return new BlockedRecipients(this, this._defaultAccountId);
|
|
1035
1296
|
}
|
|
1297
|
+
/** 카카오 채널·알림톡 템플릿. 발송은 `messages.create({ kakao: … })` 다. */
|
|
1298
|
+
get kakao() {
|
|
1299
|
+
return new Kakao(this, this._defaultAccountId);
|
|
1300
|
+
}
|
|
1036
1301
|
get webhooks() {
|
|
1037
1302
|
return new Webhooks();
|
|
1038
1303
|
}
|
|
@@ -1046,79 +1311,79 @@ var client_default_default = ClawOps;
|
|
|
1046
1311
|
|
|
1047
1312
|
Object.defineProperty(exports, "VERSION", {
|
|
1048
1313
|
enumerable: true,
|
|
1049
|
-
get: function () { return
|
|
1314
|
+
get: function () { return chunkLKFNV2GI_cjs.VERSION; }
|
|
1050
1315
|
});
|
|
1051
1316
|
Object.defineProperty(exports, "APIConnectionError", {
|
|
1052
1317
|
enumerable: true,
|
|
1053
|
-
get: function () { return
|
|
1318
|
+
get: function () { return chunkIYSPOOKH_cjs.APIConnectionError; }
|
|
1054
1319
|
});
|
|
1055
1320
|
Object.defineProperty(exports, "APIError", {
|
|
1056
1321
|
enumerable: true,
|
|
1057
|
-
get: function () { return
|
|
1322
|
+
get: function () { return chunkIYSPOOKH_cjs.APIError; }
|
|
1058
1323
|
});
|
|
1059
1324
|
Object.defineProperty(exports, "APIResponseValidationError", {
|
|
1060
1325
|
enumerable: true,
|
|
1061
|
-
get: function () { return
|
|
1326
|
+
get: function () { return chunkIYSPOOKH_cjs.APIResponseValidationError; }
|
|
1062
1327
|
});
|
|
1063
1328
|
Object.defineProperty(exports, "APIStatusError", {
|
|
1064
1329
|
enumerable: true,
|
|
1065
|
-
get: function () { return
|
|
1330
|
+
get: function () { return chunkIYSPOOKH_cjs.APIStatusError; }
|
|
1066
1331
|
});
|
|
1067
1332
|
Object.defineProperty(exports, "APITimeoutError", {
|
|
1068
1333
|
enumerable: true,
|
|
1069
|
-
get: function () { return
|
|
1334
|
+
get: function () { return chunkIYSPOOKH_cjs.APITimeoutError; }
|
|
1070
1335
|
});
|
|
1071
1336
|
Object.defineProperty(exports, "AgentConnectionError", {
|
|
1072
1337
|
enumerable: true,
|
|
1073
|
-
get: function () { return
|
|
1338
|
+
get: function () { return chunkIYSPOOKH_cjs.AgentConnectionError; }
|
|
1074
1339
|
});
|
|
1075
1340
|
Object.defineProperty(exports, "AgentError", {
|
|
1076
1341
|
enumerable: true,
|
|
1077
|
-
get: function () { return
|
|
1342
|
+
get: function () { return chunkIYSPOOKH_cjs.AgentError; }
|
|
1078
1343
|
});
|
|
1079
1344
|
Object.defineProperty(exports, "AuthenticationError", {
|
|
1080
1345
|
enumerable: true,
|
|
1081
|
-
get: function () { return
|
|
1346
|
+
get: function () { return chunkIYSPOOKH_cjs.AuthenticationError; }
|
|
1082
1347
|
});
|
|
1083
1348
|
Object.defineProperty(exports, "BadRequestError", {
|
|
1084
1349
|
enumerable: true,
|
|
1085
|
-
get: function () { return
|
|
1350
|
+
get: function () { return chunkIYSPOOKH_cjs.BadRequestError; }
|
|
1086
1351
|
});
|
|
1087
1352
|
Object.defineProperty(exports, "ClawOpsError", {
|
|
1088
1353
|
enumerable: true,
|
|
1089
|
-
get: function () { return
|
|
1354
|
+
get: function () { return chunkIYSPOOKH_cjs.ClawOpsError; }
|
|
1090
1355
|
});
|
|
1091
1356
|
Object.defineProperty(exports, "ConflictError", {
|
|
1092
1357
|
enumerable: true,
|
|
1093
|
-
get: function () { return
|
|
1358
|
+
get: function () { return chunkIYSPOOKH_cjs.ConflictError; }
|
|
1094
1359
|
});
|
|
1095
1360
|
Object.defineProperty(exports, "InternalServerError", {
|
|
1096
1361
|
enumerable: true,
|
|
1097
|
-
get: function () { return
|
|
1362
|
+
get: function () { return chunkIYSPOOKH_cjs.InternalServerError; }
|
|
1098
1363
|
});
|
|
1099
1364
|
Object.defineProperty(exports, "NotFoundError", {
|
|
1100
1365
|
enumerable: true,
|
|
1101
|
-
get: function () { return
|
|
1366
|
+
get: function () { return chunkIYSPOOKH_cjs.NotFoundError; }
|
|
1102
1367
|
});
|
|
1103
1368
|
Object.defineProperty(exports, "PermissionDeniedError", {
|
|
1104
1369
|
enumerable: true,
|
|
1105
|
-
get: function () { return
|
|
1370
|
+
get: function () { return chunkIYSPOOKH_cjs.PermissionDeniedError; }
|
|
1106
1371
|
});
|
|
1107
1372
|
Object.defineProperty(exports, "RateLimitError", {
|
|
1108
1373
|
enumerable: true,
|
|
1109
|
-
get: function () { return
|
|
1374
|
+
get: function () { return chunkIYSPOOKH_cjs.RateLimitError; }
|
|
1110
1375
|
});
|
|
1111
1376
|
Object.defineProperty(exports, "ServiceUnavailableError", {
|
|
1112
1377
|
enumerable: true,
|
|
1113
|
-
get: function () { return
|
|
1378
|
+
get: function () { return chunkIYSPOOKH_cjs.ServiceUnavailableError; }
|
|
1114
1379
|
});
|
|
1115
1380
|
Object.defineProperty(exports, "SolapiBridgeError", {
|
|
1116
1381
|
enumerable: true,
|
|
1117
|
-
get: function () { return
|
|
1382
|
+
get: function () { return chunkIYSPOOKH_cjs.SolapiBridgeError; }
|
|
1118
1383
|
});
|
|
1119
1384
|
Object.defineProperty(exports, "UnprocessableEntityError", {
|
|
1120
1385
|
enumerable: true,
|
|
1121
|
-
get: function () { return
|
|
1386
|
+
get: function () { return chunkIYSPOOKH_cjs.UnprocessableEntityError; }
|
|
1122
1387
|
});
|
|
1123
1388
|
exports.APIClient = APIClient;
|
|
1124
1389
|
exports.AccountContext = AccountContext;
|
|
@@ -1126,6 +1391,9 @@ exports.AssignmentLinks = AssignmentLinks;
|
|
|
1126
1391
|
exports.BlockedRecipients = BlockedRecipients;
|
|
1127
1392
|
exports.Calls = Calls;
|
|
1128
1393
|
exports.ClawOps = ClawOps;
|
|
1394
|
+
exports.Kakao = Kakao;
|
|
1395
|
+
exports.KakaoChannels = KakaoChannels;
|
|
1396
|
+
exports.KakaoTemplates = KakaoTemplates;
|
|
1129
1397
|
exports.Messages = Messages;
|
|
1130
1398
|
exports.Numbers = Numbers;
|
|
1131
1399
|
exports.Page = Page;
|