@k-msg/core 0.4.0 → 0.6.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,76 +0,0 @@
1
- import type { DeliveryStatus, StandardRequest, StandardResult } from "./standard";
2
- export type ProviderType = "messaging" | "sms" | "email" | "push" | "voice";
3
- export interface ProviderConfig {
4
- apiKey: string;
5
- baseUrl: string;
6
- timeout?: number;
7
- retries?: number;
8
- debug?: boolean;
9
- [key: string]: any;
10
- }
11
- export interface ConfigurationSchema {
12
- required: ConfigField[];
13
- optional: ConfigField[];
14
- }
15
- export interface ConfigField {
16
- key: string;
17
- type: "string" | "number" | "boolean" | "url" | "secret";
18
- description: string;
19
- validation?: {
20
- pattern?: string;
21
- min?: number;
22
- max?: number;
23
- enum?: string[];
24
- };
25
- }
26
- export interface ProviderHealthStatus {
27
- healthy: boolean;
28
- issues: string[];
29
- latency?: number;
30
- data?: Record<string, unknown>;
31
- }
32
- export interface ProviderMetadata {
33
- id: string;
34
- name: string;
35
- version: string;
36
- description?: string;
37
- supportedFeatures: string[];
38
- capabilities: Record<string, any>;
39
- endpoints: Record<string, string>;
40
- authType?: string;
41
- responseFormat?: string;
42
- }
43
- export interface ProviderFactoryConfig {
44
- providers: Record<string, ProviderConfig>;
45
- }
46
- export declare abstract class BaseProviderAdapter {
47
- protected config: ProviderConfig;
48
- constructor(config: ProviderConfig);
49
- abstract adaptRequest(request: StandardRequest): any;
50
- abstract adaptResponse(response: any): StandardResult;
51
- abstract mapError(error: any): import("./standard").StandardError;
52
- abstract getAuthHeaders(): Record<string, string>;
53
- abstract getBaseUrl(): string;
54
- abstract getEndpoint(operation: string): string;
55
- getRequestConfig(): RequestInit;
56
- validateResponse(response: Response): boolean;
57
- protected generateMessageId(): string;
58
- protected log(message: string, data?: any): void;
59
- isRetryableError(error: any): boolean;
60
- }
61
- export interface BaseProvider<TRequest = StandardRequest, TResult = StandardResult> {
62
- readonly id: string;
63
- readonly name: string;
64
- readonly type: string;
65
- readonly version: string;
66
- healthCheck(): Promise<ProviderHealthStatus>;
67
- send<T extends TRequest = TRequest, R extends TResult = TResult>(request: T): Promise<R>;
68
- getStatus?(requestId: string): Promise<DeliveryStatus>;
69
- cancel?(requestId: string): Promise<boolean>;
70
- destroy?(): void;
71
- }
72
- export interface AdapterFactory {
73
- create(config: ProviderConfig): any;
74
- supports(providerId: string): boolean;
75
- getMetadata(): ProviderMetadata;
76
- }
@@ -1,134 +0,0 @@
1
- import type { Button, MessageType } from "./message";
2
- export interface DeliveryStatus {
3
- status: "pending" | "sent" | "delivered" | "failed" | "cancelled";
4
- timestamp: Date;
5
- details?: Record<string, unknown>;
6
- }
7
- export declare enum StandardStatus {
8
- PENDING = "PENDING",
9
- SENT = "SENT",
10
- DELIVERED = "DELIVERED",
11
- FAILED = "FAILED",
12
- CANCELLED = "CANCELLED"
13
- }
14
- export declare enum StandardErrorCode {
15
- UNKNOWN_ERROR = "UNKNOWN_ERROR",
16
- INVALID_REQUEST = "INVALID_REQUEST",
17
- AUTHENTICATION_FAILED = "AUTHENTICATION_FAILED",
18
- INSUFFICIENT_BALANCE = "INSUFFICIENT_BALANCE",
19
- TEMPLATE_NOT_FOUND = "TEMPLATE_NOT_FOUND",
20
- RATE_LIMIT_EXCEEDED = "RATE_LIMIT_EXCEEDED",
21
- PROVIDER_ERROR = "PROVIDER_ERROR",
22
- NETWORK_ERROR = "NETWORK_ERROR"
23
- }
24
- export interface StandardError {
25
- code: StandardErrorCode;
26
- message: string;
27
- retryable: boolean;
28
- details?: Record<string, unknown>;
29
- }
30
- export interface StandardRequest {
31
- channel?: MessageType;
32
- templateCode: string;
33
- phoneNumber: string;
34
- variables: Record<string, unknown>;
35
- text?: string;
36
- imageUrl?: string;
37
- buttons?: Button[];
38
- options?: {
39
- scheduledAt?: Date;
40
- senderNumber?: string;
41
- subject?: string;
42
- /**
43
- * Optional international country code for providers that support it (e.g. SOLAPI).
44
- */
45
- country?: string;
46
- /**
47
- * Provider-supported custom fields (string values only).
48
- */
49
- customFields?: Record<string, string>;
50
- /**
51
- * Provider-specific KakaoTalk options (e.g. SOLAPI kakaoOptions).
52
- */
53
- kakaoOptions?: {
54
- pfId?: string;
55
- templateId?: string;
56
- variables?: Record<string, string>;
57
- disableSms?: boolean;
58
- adFlag?: boolean;
59
- buttons?: unknown[];
60
- imageId?: string;
61
- [key: string]: unknown;
62
- };
63
- /**
64
- * Provider-specific Naver SmartAlert options (e.g. SOLAPI naverOptions).
65
- */
66
- naverOptions?: {
67
- talkId?: string;
68
- templateId?: string;
69
- disableSms?: boolean;
70
- variables?: Record<string, string>;
71
- buttons?: unknown[];
72
- [key: string]: unknown;
73
- };
74
- /**
75
- * Provider-specific voice(TTS) options (e.g. SOLAPI voiceOptions).
76
- */
77
- voiceOptions?: {
78
- voiceType: "FEMALE" | "MALE";
79
- headerMessage?: string;
80
- tailMessage?: string;
81
- replyRange?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
82
- counselorNumber?: string;
83
- [key: string]: unknown;
84
- };
85
- /**
86
- * Provider-specific fax options (e.g. SOLAPI faxOptions).
87
- */
88
- faxOptions?: {
89
- fileIds?: string[];
90
- fileUrls?: string[];
91
- [key: string]: unknown;
92
- };
93
- /**
94
- * Provider-specific RCS options (e.g. SOLAPI rcsOptions).
95
- */
96
- rcsOptions?: {
97
- brandId?: string;
98
- templateId?: string;
99
- copyAllowed?: boolean;
100
- variables?: Record<string, string>;
101
- mmsType?: "M3" | "S3" | "M4" | "S4" | "M5" | "S5" | "M6" | "S6";
102
- commercialType?: boolean;
103
- disableSms?: boolean;
104
- buttons?: unknown[];
105
- additionalBody?: {
106
- title?: string;
107
- description?: string;
108
- imageId?: string;
109
- buttons?: unknown[];
110
- [key: string]: unknown;
111
- };
112
- [key: string]: unknown;
113
- };
114
- [key: string]: any;
115
- };
116
- }
117
- export interface StandardResult {
118
- messageId: string;
119
- status: StandardStatus;
120
- provider: string;
121
- timestamp: Date;
122
- phoneNumber: string;
123
- error?: StandardError;
124
- metadata?: Record<string, unknown>;
125
- }
126
- export declare enum TemplateCategory {
127
- AUTHENTICATION = "AUTHENTICATION",
128
- NOTIFICATION = "NOTIFICATION",
129
- PROMOTION = "PROMOTION",
130
- INFORMATION = "INFORMATION",
131
- RESERVATION = "RESERVATION",
132
- SHIPPING = "SHIPPING",
133
- PAYMENT = "PAYMENT"
134
- }
@@ -1,55 +0,0 @@
1
- /**
2
- * Universal Provider Implementation
3
- * 어댑터 패턴을 사용한 범용 프로바이더
4
- */
5
- import { type BaseProvider, type BaseProviderAdapter, type ConfigurationSchema, type DeliveryStatus, type ProviderHealthStatus, type StandardRequest, type StandardResult } from "./types/index";
6
- /**
7
- * 어댑터 기반 범용 프로바이더
8
- * 모든 프로바이더가 이 클래스를 사용하여 표준 인터페이스 구현
9
- */
10
- export declare class UniversalProvider implements BaseProvider<StandardRequest, StandardResult> {
11
- readonly id: string;
12
- readonly name: string;
13
- readonly type: "messaging";
14
- readonly version: string;
15
- private adapter;
16
- private config;
17
- private isConfigured;
18
- constructor(adapter: BaseProviderAdapter, metadata: {
19
- id: string;
20
- name: string;
21
- version: string;
22
- });
23
- configure(config: Record<string, unknown>): void;
24
- isReady(): boolean;
25
- healthCheck(): Promise<ProviderHealthStatus>;
26
- destroy(): void;
27
- send<T extends StandardRequest = StandardRequest, R extends StandardResult = StandardResult>(request: T): Promise<R>;
28
- getStatus(requestId: string): Promise<DeliveryStatus>;
29
- cancel(requestId: string): Promise<boolean>;
30
- getCapabilities(): any;
31
- getSupportedFeatures(): string[];
32
- getConfigurationSchema(): ConfigurationSchema;
33
- /**
34
- * HTTP 요청 실행
35
- */
36
- private makeHttpRequest;
37
- /**
38
- * 표준 상태를 DeliveryStatus로 변환
39
- */
40
- private mapStandardStatusToDeliveryStatus;
41
- /**
42
- * 어댑터 인스턴스 반환 (고급 사용자용)
43
- */
44
- getAdapter(): BaseProviderAdapter;
45
- /**
46
- * 프로바이더 메타데이터 반환
47
- */
48
- getMetadata(): {
49
- id: string;
50
- name: string;
51
- version: string;
52
- type: "messaging";
53
- adapter: string;
54
- };
55
- }