@k-msg/core 0.7.3 → 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.
@@ -1,6 +1,6 @@
1
1
  import type { KMsgError } from "./errors";
2
2
  import type { Result } from "./result";
3
- import type { DeliveryStatusQuery, DeliveryStatusResult, MessageType, SendOptions, SendResult } from "./types/index";
3
+ import type { DeliveryStatusQuery, DeliveryStatusResult, KakaoChannel, KakaoChannelCategories, MessageType, SendOptions, SendResult } from "./types/index";
4
4
  export interface Template {
5
5
  id: string;
6
6
  code: string;
@@ -13,16 +13,50 @@ export interface Template {
13
13
  createdAt: Date;
14
14
  updatedAt: Date;
15
15
  }
16
+ export type TemplateCreateInput = {
17
+ name: string;
18
+ content: string;
19
+ category?: string;
20
+ buttons?: unknown[];
21
+ variables?: string[];
22
+ };
23
+ export type TemplateUpdateInput = Partial<TemplateCreateInput>;
24
+ export type TemplateContext = {
25
+ /**
26
+ * Provider-specific Kakao channel key (e.g. Aligo senderKey).
27
+ */
28
+ kakaoChannelSenderKey?: string;
29
+ };
16
30
  export interface TemplateProvider {
17
- createTemplate(template: Omit<Template, "id" | "status" | "createdAt" | "updatedAt">): Promise<Result<Template, KMsgError>>;
18
- updateTemplate(code: string, template: Partial<Omit<Template, "id" | "code" | "status" | "createdAt" | "updatedAt">>): Promise<Result<Template, KMsgError>>;
19
- deleteTemplate(code: string): Promise<Result<void, KMsgError>>;
20
- getTemplate(code: string): Promise<Result<Template, KMsgError>>;
31
+ createTemplate(input: TemplateCreateInput, ctx?: TemplateContext): Promise<Result<Template, KMsgError>>;
32
+ updateTemplate(code: string, patch: TemplateUpdateInput, ctx?: TemplateContext): Promise<Result<Template, KMsgError>>;
33
+ deleteTemplate(code: string, ctx?: TemplateContext): Promise<Result<void, KMsgError>>;
34
+ getTemplate(code: string, ctx?: TemplateContext): Promise<Result<Template, KMsgError>>;
21
35
  listTemplates(params?: {
22
36
  status?: string;
23
37
  page?: number;
24
38
  limit?: number;
25
- }): Promise<Result<Template[], KMsgError>>;
39
+ }, ctx?: TemplateContext): Promise<Result<Template[], KMsgError>>;
40
+ }
41
+ export interface TemplateInspectionProvider {
42
+ requestTemplateInspection(code: string, ctx?: TemplateContext): Promise<Result<void, KMsgError>>;
43
+ }
44
+ export interface KakaoChannelProvider {
45
+ listKakaoChannels(params?: {
46
+ plusId?: string;
47
+ senderKey?: string;
48
+ }): Promise<Result<KakaoChannel[], KMsgError>>;
49
+ listKakaoChannelCategories?(): Promise<Result<KakaoChannelCategories, KMsgError>>;
50
+ requestKakaoChannelAuth?(params: {
51
+ plusId: string;
52
+ phoneNumber: string;
53
+ }): Promise<Result<void, KMsgError>>;
54
+ addKakaoChannel?(params: {
55
+ plusId: string;
56
+ authNum: string;
57
+ phoneNumber: string;
58
+ categoryCode: string;
59
+ }): Promise<Result<KakaoChannel, KMsgError>>;
26
60
  }
27
61
  export interface ProviderHealthStatus {
28
62
  healthy: boolean;
@@ -1,4 +1,5 @@
1
1
  export * from "./balance";
2
2
  export * from "./delivery-status";
3
3
  export * from "./history";
4
+ export * from "./kakao-channel";
4
5
  export * from "./message";
@@ -0,0 +1,28 @@
1
+ export interface KakaoChannel {
2
+ providerId: string;
3
+ /**
4
+ * Provider-specific Kakao channel key.
5
+ * - Aligo: senderKey
6
+ * - Solapi: pfId (profileId)
7
+ */
8
+ senderKey: string;
9
+ /**
10
+ * Kakao channel id including "@", when available (e.g. "@mybrand").
11
+ */
12
+ plusId?: string;
13
+ name?: string;
14
+ status?: string;
15
+ createdAt?: Date;
16
+ updatedAt?: Date;
17
+ raw?: unknown;
18
+ }
19
+ export interface KakaoCategoryEntry {
20
+ code: string;
21
+ name: string;
22
+ parentCode?: string;
23
+ }
24
+ export interface KakaoChannelCategories {
25
+ first: KakaoCategoryEntry[];
26
+ second: KakaoCategoryEntry[];
27
+ third: KakaoCategoryEntry[];
28
+ }
@@ -76,6 +76,18 @@ export interface KakaoSendOptions {
76
76
  imageLink?: string;
77
77
  [key: string]: any;
78
78
  }
79
+ export interface AlimTalkFailoverOptions {
80
+ enabled?: boolean;
81
+ fallbackChannel?: "sms" | "lms";
82
+ fallbackContent?: string;
83
+ fallbackTitle?: string;
84
+ }
85
+ export type SendWarningCode = "FAILOVER_UNSUPPORTED_PROVIDER" | "FAILOVER_PARTIAL_PROVIDER" | "FALLBACK_CONTENT_MISSING" | (string & {});
86
+ export interface SendWarning {
87
+ code: SendWarningCode;
88
+ message: string;
89
+ details?: Record<string, unknown>;
90
+ }
79
91
  export interface NaverSendOptions {
80
92
  talkId?: string;
81
93
  /**
@@ -144,6 +156,7 @@ export interface AlimTalkSendOptions extends CommonSendOptions {
144
156
  templateCode: string;
145
157
  variables: MessageVariables;
146
158
  kakao?: KakaoSendOptions;
159
+ failover?: AlimTalkFailoverOptions;
147
160
  }
148
161
  export interface FriendTalkSendOptions extends CommonSendOptions {
149
162
  type: "FRIENDTALK";
@@ -213,5 +226,6 @@ export interface SendResult {
213
226
  status: MessageStatus;
214
227
  type: MessageType;
215
228
  to: string;
229
+ warnings?: SendWarning[];
216
230
  raw?: unknown;
217
231
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k-msg/core",
3
- "version": "0.7.3",
3
+ "version": "0.9.0",
4
4
  "packageManager": "bun@1.3.8",
5
5
  "description": "Core types and interfaces for K-Message platform",
6
6
  "type": "module",